Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tarquas/mongoose-hook-revision
Mongoose plugin, adding revision field to documents, which gets increased on each update (not only arrays, as internal versioning does). Also, disables internal versioning.
https://github.com/tarquas/mongoose-hook-revision
Last synced: about 2 months ago
JSON representation
Mongoose plugin, adding revision field to documents, which gets increased on each update (not only arrays, as internal versioning does). Also, disables internal versioning.
- Host: GitHub
- URL: https://github.com/tarquas/mongoose-hook-revision
- Owner: tarquas
- License: mit
- Created: 2015-02-05T20:54:16.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-05-08T18:22:28.000Z (over 9 years ago)
- Last Synced: 2024-04-24T11:10:33.330Z (9 months ago)
- Language: JavaScript
- Size: 195 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mongoose-hook-revision
Mongoose plugin, adding revision field to documents, which gets increased on each update (not only arrays, as internal versioning does). Also, disables internal versioning.# Installation
```shell
git clone [email protected]:tarquas/mongoose-hook-revision.git mongoose-hook-revision
```# Package
```js
{
"mongoose-hook-revision": "0.1.3"
}
```# Usage
Example: enable 'revision' field on a schema:
```js
var
mongoose = require('mongoose'),
revisionPlugin = require('mongoose-hook-revision'),
PersonSchema;PersonSchema = {
name: String,
email: String
};PersonSchema.plugin(revisionPlugin, {mongoose: mongoose, path: 'revision'});
mongoose.model('Person', PersonSchema);
```# Notes
* This plugin must be provided with an exact instance of `mongoose`, where the processing models expected to be processed, in `opts` parameter.
* This plugin makes a revision on any document update operation. It's based on `mongoose-hook` plugin, so every time, any of `insert`, `update`, or `findAndModify` database API wrapper is called, the revision is increased.