mongoose-hook-revision
v0.1.3
Published
Mongoose plugin, adding revision field to documents, which gets increased on each update (not only arrays, as internal versioning does). Also, disables internal versioning.
Downloads
4,093
Maintainers
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
git clone [email protected]:tarquas/mongoose-hook-revision.git mongoose-hook-revision
Package
{
"mongoose-hook-revision": "0.1.3"
}
Usage
Example: enable 'revision' field on a schema:
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, inopts
parameter.This plugin makes a revision on any document update operation. It's based on
mongoose-hook
plugin, so every time, any ofinsert
,update
, orfindAndModify
database API wrapper is called, the revision is increased.