Document versioning plugin for Mongoose
npm install mongoose-versionerversion: 0.1.0
This is a Mongoose plugin that, when applied to a model, will provide
the ability to create multiple versions of a document and set one of
the versions as the active document.
All of the document versions are stored in a dynamically created shadow
collection and the active document is stored in your originally created
collection.
Install the plugin on the model you want to version.
``
// models/foo.js
var mongoose = require('mongoose')
, versioner = require('mongoose-versioner')
, FooSchema = new mongoose.Schema({
title: {'type': String, 'default': 'Untitled'},
});
FooSchema.plugin(versioner, {modelName:'Foo', mongoose:mongoose});
module.exports = mongoose.model('Foo', FooSchema);
``
NOTE: When using this plugin it is expected that all public facing queries
would be performed on your models using mongoose in the traditional
way. These static methods are for you to use in your CMS when content
creators are editing their documents.
- API documentation
- Add test scripts
Copyright (c) 2013 James O'Reilly <james@jamesor.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.