Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joaolucasl/mongoose-notekeeper-plugin
A simple Mongoose plugin to keep track of changes in your documents.
https://github.com/joaolucasl/mongoose-notekeeper-plugin
mongoose mongoose-plugin typescript-library
Last synced: about 1 month ago
JSON representation
A simple Mongoose plugin to keep track of changes in your documents.
- Host: GitHub
- URL: https://github.com/joaolucasl/mongoose-notekeeper-plugin
- Owner: joaolucasl
- License: lgpl-3.0
- Created: 2019-07-04T17:07:47.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T03:41:02.000Z (almost 2 years ago)
- Last Synced: 2024-09-28T20:42:22.375Z (about 2 months ago)
- Topics: mongoose, mongoose-plugin, typescript-library
- Language: JavaScript
- Size: 1.13 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# mongoose-notekeeper-plugin
## Installation
```bash
yarn add mongoose-notekeeper-plugin
```## How To Use
```javascript
// ...
const notekeeperPlugin = require("mongoose-notekeeper-plugin");const ProductSchema = new Schema({
name: String,
type: String,
price: Number,
quantity: Number,
description: String,
status: String
});notekeeperPlugin(ProductSchema, { fields: ["quantity", "status"] });
```This will create new `history` fields named after the original field (e.g. `status_history` for `status`).
Whenever the fields listed in `fields` are updated, a new entry in an array will be added. It will have the following format:```Typescript
{
before: Mongoose.SchemaType,
after: Mongoose.SchemaType,
timestamp: Date
}
```