{"_id":"mongoose-rollback","_rev":"26-16dbd73d1df79ce173442b171d15a8c4","name":"mongoose-rollback","description":"mongoose rollback machine","dist-tags":{"latest":"1.1.4"},"versions":{"1.0.0":{"name":"mongoose-rollback","version":"1.0.0","description":"mongoose rollback machine","main":"mongoose-rollback.js","dependencies":{"lodash":"^2.4.1","mongoose":"^3.8.18","should":"^4.1.0"},"devDependencies":{"mocha":"^2.0.1"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git@github.com:Snkz/mongoose-rollback.git"},"keywords":["mongo","mongoose","history","revisions","rollback"],"author":{"name":"Abdi Dahir"},"license":"ISC","bugs":{"url":"https://github.com/Snkz/mongoose-rollback/issues"},"homepage":"https://github.com/Snkz/mongoose-rollback","gitHead":"6862c623999193177774ba9745b71ab79d7c6030","_id":"mongoose-rollback@1.0.0","_shasum":"f5815b582a0e2d4df64af88d75c453fef151f891","_from":".","_npmVersion":"1.4.27","_npmUser":{"name":"snkz","email":"abdi.dahir@outlook.com"},"maintainers":[{"name":"snkz","email":"abdi.dahir@outlook.com"}],"dist":{"shasum":"f5815b582a0e2d4df64af88d75c453fef151f891","tarball":"https://registry.npmjs.org/mongoose-rollback/-/mongoose-rollback-1.0.0.tgz","integrity":"sha512-tPOSNJKQ2UncG1No7MCcg4+XwWM1T4JzyHGyIlu8MGKHka8XeytADmFnGOlAdQ9CZv7bFRTGbeRs9wwqUfw3lw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICPSJD3VMC+V1YU4rRd6R5n1QHgmRHEkpJT6D5DW1aJeAiAbGrG1XIvduakcDbVfUvIXyLTqavU6MHh6AtTXa8YD+Q=="}]}},"1.0.1":{"name":"mongoose-rollback","version":"1.0.1","description":"mongoose rollback machine","main":"mongoose-rollback.js","dependencies":{"mongoose":"^3.8.18"},"devDependencies":{"mocha":"^2.0.1","should":"^4.1.0"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git@github.com:Snkz/mongoose-rollback.git"},"keywords":["mongo","mongoose","history","revisions","rollback"],"author":{"name":"Abdi Dahir"},"license":"ISC","bugs":{"url":"https://github.com/Snkz/mongoose-rollback/issues"},"homepage":"https://github.com/Snkz/mongoose-rollback","gitHead":"57c2c7f6e82c981a78f6338cfeb580f58d9210c5","_id":"mongoose-rollback@1.0.1","_shasum":"97481fdbdde88b58027d563a60386137fae3b50a","_from":".","_npmVersion":"1.4.27","_npmUser":{"name":"snkz","email":"abdi.dahir@outlook.com"},"maintainers":[{"name":"snkz","email":"abdi.dahir@outlook.com"}],"dist":{"shasum":"97481fdbdde88b58027d563a60386137fae3b50a","tarball":"https://registry.npmjs.org/mongoose-rollback/-/mongoose-rollback-1.0.1.tgz","integrity":"sha512-i9E4xZbux/B9GkdbH5rUk395aJmn2y68lgZTOBD6oWkmOAB0IFE2jZFSvd+Z1COjWNm5Upskq08cZ5Lo0R4B1Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICSTWz13kUE2sAdrW5nsC4a/MZbzUmCSxt+cm1iaZc84AiAvypjvPa/Q5zLEy28jDCFBe4CarLOVG9kbO5wI3W+RfQ=="}]}},"1.0.2":{"name":"mongoose-rollback","version":"1.0.2","description":"mongoose rollback machine","main":"mongoose-rollback.js","dependencies":{"mongoose":"^3.8.18"},"devDependencies":{"mocha":"^2.0.1","should":"^4.1.0"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git@github.com:Snkz/mongoose-rollback.git"},"keywords":["mongo","mongodb","mongoose","history","revisions","rollback"],"author":{"name":"Abdi Dahir"},"license":"ISC","bugs":{"url":"https://github.com/Snkz/mongoose-rollback/issues"},"homepage":"https://github.com/Snkz/mongoose-rollback","gitHead":"58d960f972603364e306f45e9de2b30ac8e4f8d6","_id":"mongoose-rollback@1.0.2","_shasum":"4a9d487949574a0d7542a48a4961ba5d0fd525f1","_from":".","_npmVersion":"1.4.27","_npmUser":{"name":"snkz","email":"abdi.dahir@outlook.com"},"maintainers":[{"name":"snkz","email":"abdi.dahir@outlook.com"}],"dist":{"shasum":"4a9d487949574a0d7542a48a4961ba5d0fd525f1","tarball":"https://registry.npmjs.org/mongoose-rollback/-/mongoose-rollback-1.0.2.tgz","integrity":"sha512-C3rwBQfeKSnOzro4FTEc2eS78YMy4gZR80MyDDupaI31ugVJ6hF1I3AiRU6Urg+HW5GV8gVe/zZqfkxTb9wVUQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCAKEs1hwGBnO0OkdTK+CcBr6TYsu17QY5q3/XnwSCX1gIhAO4u3ObIbeDnB/cZdt7HRh69b1/VTLpjRwPD940FEhNm"}]}},"1.0.3":{"name":"mongoose-rollback","version":"1.0.3","description":"mongoose rollback machine","main":"mongoose-rollback.js","dependencies":{"mongoose":"^3.8.18"},"devDependencies":{"mocha":"^2.0.1","should":"^4.1.0"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git@github.com:Snkz/mongoose-rollback.git"},"keywords":["mongo","mongodb","mongoose","history","revisions","rollback"],"author":{"name":"Abdi Dahir"},"license":"ISC","bugs":{"url":"https://github.com/Snkz/mongoose-rollback/issues"},"homepage":"https://github.com/Snkz/mongoose-rollback","gitHead":"888d6d77b555d1066af7d854deabcf4141cd03f3","_id":"mongoose-rollback@1.0.3","_shasum":"68091c324f3c4072f2e648ff6c596cda255a3254","_from":".","_npmVersion":"1.4.27","_npmUser":{"name":"snkz","email":"abdi.dahir@outlook.com"},"maintainers":[{"name":"snkz","email":"abdi.dahir@outlook.com"}],"dist":{"shasum":"68091c324f3c4072f2e648ff6c596cda255a3254","tarball":"https://registry.npmjs.org/mongoose-rollback/-/mongoose-rollback-1.0.3.tgz","integrity":"sha512-XBHOw5IV8omUg4nx6DpVsnvBSvZadoVicy5NGzcIbvpTVJo9IG31Ci2RdNvhttqRIs7wuqBeLLk/UuUYLzM3wQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBZZI0sf8hgacDbOKYQGStKs7gn/Wv5nuGwv8NLFk+ZHAiEAotz0RguXEhirf6QgD2z6jZgmbG8y4mq7WrityzzXLB4="}]}},"1.0.4":{"name":"mongoose-rollback","version":"1.0.4","description":"mongoose rollback machine","main":"mongoose-rollback.js","dependencies":{"mongoose":"^3.8.18"},"devDependencies":{"mocha":"^2.0.1","should":"^4.1.0"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git@github.com:Snkz/mongoose-rollback.git"},"keywords":["mongo","mongodb","mongoose","history","revisions","rollback"],"author":{"name":"Abdi Dahir"},"license":"ISC","bugs":{"url":"https://github.com/Snkz/mongoose-rollback/issues"},"homepage":"https://github.com/Snkz/mongoose-rollback","gitHead":"d209b8d612984995aae50f5947f317888888f2b3","_id":"mongoose-rollback@1.0.4","_shasum":"cb5e365ecf3e05ca7994a099ceb76f766542ef21","_from":".","_npmVersion":"1.4.27","_npmUser":{"name":"snkz","email":"abdi.dahir@outlook.com"},"maintainers":[{"name":"snkz","email":"abdi.dahir@outlook.com"}],"dist":{"shasum":"cb5e365ecf3e05ca7994a099ceb76f766542ef21","tarball":"https://registry.npmjs.org/mongoose-rollback/-/mongoose-rollback-1.0.4.tgz","integrity":"sha512-n7GpdjQIQoOuQS8n3ocErDNad3BnJbAAlFnd6jYkgg3MOOT7B6Sb5rhMWdpOpIfrjG3PZc+K3g9oZ4Jf569kiw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCrRV8oBaUL4kC/nfk06okJplWFGfNOKNie4wMjUp12CQIgHoinZG7VED4ToS2pmQqmmOzXXqYMeDcHZwkmLVcYKAc="}]}},"1.0.5":{"name":"mongoose-rollback","version":"1.0.5","description":"mongoose rollback machine","main":"mongoose-rollback.js","dependencies":{"mongoose":"^3.8.18"},"devDependencies":{"mocha":"^2.0.1","should":"^4.1.0"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git@github.com:Snkz/mongoose-rollback.git"},"keywords":["mongo","mongodb","mongoose","history","revisions","rollback"],"author":{"name":"Abdi Dahir"},"license":"ISC","bugs":{"url":"https://github.com/Snkz/mongoose-rollback/issues"},"homepage":"https://github.com/Snkz/mongoose-rollback","gitHead":"2df3558df58eaf455981825ff3cb9749186c66cb","_id":"mongoose-rollback@1.0.5","_shasum":"06dc58db16acb85d5dbd9de68dfc644064490be4","_from":".","_npmVersion":"1.4.27","_npmUser":{"name":"snkz","email":"abdi.dahir@outlook.com"},"maintainers":[{"name":"snkz","email":"abdi.dahir@outlook.com"}],"dist":{"shasum":"06dc58db16acb85d5dbd9de68dfc644064490be4","tarball":"https://registry.npmjs.org/mongoose-rollback/-/mongoose-rollback-1.0.5.tgz","integrity":"sha512-TcjHJyQ5d9pO5t/lixTEZ6lDrA5NZI72IzbvqN/cCaKeiu/DZ+7PD0wftOojsr7n6oiGIGgIIeEf+fLwg6L3SQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEDo+mWqNDXXQZOzMIjOvFeRBhx5ANMXQkYZYFvVxLJ0AiAS7MIxR3dz4QyKDMye4wyENrFeuVjaNAgbxCuMjU3Nhg=="}]}},"1.1.0":{"name":"mongoose-rollback","version":"1.1.0","description":"mongoose rollback machine","main":"mongoose-rollback.js","dependencies":{"mongoose":"^3.8.18"},"devDependencies":{"mocha":"^2.0.1","should":"^4.1.0"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git@github.com:Snkz/mongoose-rollback.git"},"keywords":["mongo","mongodb","mongoose","history","revisions","rollback"],"author":{"name":"Abdi Dahir"},"license":"ISC","bugs":{"url":"https://github.com/Snkz/mongoose-rollback/issues"},"homepage":"https://github.com/Snkz/mongoose-rollback","gitHead":"59028f156760db91b2e3639afeb997032c78fca1","_id":"mongoose-rollback@1.1.0","_shasum":"a2f989fcf52ffa87b11fb83c0eb7722447289a25","_from":".","_npmVersion":"1.4.27","_npmUser":{"name":"snkz","email":"abdi.dahir@outlook.com"},"maintainers":[{"name":"snkz","email":"abdi.dahir@outlook.com"}],"dist":{"shasum":"a2f989fcf52ffa87b11fb83c0eb7722447289a25","tarball":"https://registry.npmjs.org/mongoose-rollback/-/mongoose-rollback-1.1.0.tgz","integrity":"sha512-XYvOBEJTBFvsDgbnI6WMIpxHeQ4lXmVtQk5JEq1/EcaXObdk404QIEmZPT82IXY86FguLINO48huOdao1G9TjA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIERgfyc+v2Q1KM+NIxudB7gGAQnuzsghuRzx1q32bK3VAiEAh/Y0o9C9M+d8sgpHrEIKqy+FqdL4HCb95y4iMkPVSmg="}]}},"1.1.1":{"name":"mongoose-rollback","version":"1.1.1","description":"mongoose rollback machine","main":"mongoose-rollback.js","dependencies":{"mongoose":"^3.8.18"},"devDependencies":{"mocha":"^2.0.1","should":"^4.1.0"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git@github.com:Snkz/mongoose-rollback.git"},"keywords":["mongo","mongodb","mongoose","history","revisions","rollback"],"author":{"name":"Abdi Dahir"},"license":"ISC","bugs":{"url":"https://github.com/Snkz/mongoose-rollback/issues"},"homepage":"https://github.com/Snkz/mongoose-rollback","gitHead":"ada8637a796b1960ab189f16c8113f636169b245","_id":"mongoose-rollback@1.1.1","_shasum":"606dad143d2d7ced272f5dcb80cb7d94dca5c478","_from":".","_npmVersion":"1.4.27","_npmUser":{"name":"snkz","email":"abdi.dahir@outlook.com"},"maintainers":[{"name":"snkz","email":"abdi.dahir@outlook.com"}],"dist":{"shasum":"606dad143d2d7ced272f5dcb80cb7d94dca5c478","tarball":"https://registry.npmjs.org/mongoose-rollback/-/mongoose-rollback-1.1.1.tgz","integrity":"sha512-0ciaXmYIl+Fh0ekTjI2ZsSkZtKhSqMez3OG4YHN7DKewjPaFkrWzkUy9fhW7Euds00bdZxZktj8Wc/tnHp/LVQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIED0+od4RTXUfD2rA+4EpppLnc4Wk7dLRAoMXfPDCoSxAiBELbGmXbrl4DwKVN/8HdWnFMTgCRgiO9F6Tf85WdHuJw=="}]}},"1.1.2":{"name":"mongoose-rollback","version":"1.1.2","description":"mongoose rollback machine","main":"mongoose-rollback.js","dependencies":{"mongoose":"^3.8.18"},"devDependencies":{"mocha":"^2.0.1","should":"^4.1.0"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git@github.com:Snkz/mongoose-rollback.git"},"keywords":["mongo","mongodb","mongoose","history","revisions","rollback"],"author":{"name":"Abdi Dahir"},"license":"ISC","bugs":{"url":"https://github.com/Snkz/mongoose-rollback/issues"},"homepage":"https://github.com/Snkz/mongoose-rollback","gitHead":"cb8c2ded324b13eab193c225cb6672a928104521","_id":"mongoose-rollback@1.1.2","_shasum":"15609480fe999359a21635d35ac99785f0e7f175","_from":".","_npmVersion":"1.4.27","_npmUser":{"name":"snkz","email":"abdi.dahir@outlook.com"},"maintainers":[{"name":"snkz","email":"abdi.dahir@outlook.com"}],"dist":{"shasum":"15609480fe999359a21635d35ac99785f0e7f175","tarball":"https://registry.npmjs.org/mongoose-rollback/-/mongoose-rollback-1.1.2.tgz","integrity":"sha512-zUSqJi/v2/cQmKlDk8s6cGIySGVm0vYz5G6DwxvqLPvG5RUulPWuRYWuICtIsWGMWopGeRQetEQGtjA47EzuWQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIASCrrTqTG3ppEYpLqnU7eqFh7rvKrgR224dN1D4U7BpAiEA08RBqL/nMVulUP44J8rw5XGPimcr5ovUVWZGyVYe2fs="}]}},"1.1.3":{"name":"mongoose-rollback","version":"1.1.3","description":"mongoose rollback machine","main":"mongoose-rollback.js","dependencies":{"mongoose":"^3.8.18"},"devDependencies":{"mocha":"^2.0.1","should":"^4.1.0"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git@github.com:Snkz/mongoose-rollback.git"},"keywords":["mongo","mongodb","mongoose","history","revisions","rollback"],"author":{"name":"Abdi Dahir"},"license":"ISC","bugs":{"url":"https://github.com/Snkz/mongoose-rollback/issues"},"homepage":"https://github.com/Snkz/mongoose-rollback","gitHead":"7a83b0090ccfcc73bddd5ee084c9c5e8aa0e284c","_id":"mongoose-rollback@1.1.3","_shasum":"e981c56448dc0adcc3414cec7c8e35f99ef9ecd6","_from":".","_npmVersion":"1.4.27","_npmUser":{"name":"snkz","email":"abdi.dahir@outlook.com"},"maintainers":[{"name":"snkz","email":"abdi.dahir@outlook.com"}],"dist":{"shasum":"e981c56448dc0adcc3414cec7c8e35f99ef9ecd6","tarball":"https://registry.npmjs.org/mongoose-rollback/-/mongoose-rollback-1.1.3.tgz","integrity":"sha512-TaHab2eZ9dFwzOH/vrbJp35e7xUtn70sy3pWK5AIUFyyITmAjBb8ijuM7R2bSG+e/4vmDejLEWLeqQNWM++Rsg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG6oEMnaACym5aRKGn8cD+r9imH0WHy7pFi+VsTqzzoWAiBc4mlA9B9eq6sLfdTVxUXy7ENCwighdlw/pszsoCXiOA=="}]}},"1.1.4":{"name":"mongoose-rollback","version":"1.1.4","description":"mongoose rollback machine","main":"mongoose-rollback.js","dependencies":{"mongoose":"^4.0.5"},"devDependencies":{"mocha":"^2.0.1","should":"^4.1.0"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git+ssh://git@github.com/Snkz/mongoose-rollback.git"},"keywords":["mongo","mongodb","mongoose","history","revisions","rollback"],"author":{"name":"Abdi Dahir"},"license":"ISC","bugs":{"url":"https://github.com/Snkz/mongoose-rollback/issues"},"homepage":"https://github.com/Snkz/mongoose-rollback","gitHead":"6c08d01b50082b7ea359e74bac8216403d542e06","_id":"mongoose-rollback@1.1.4","_shasum":"38dd04d9e55a0fa4fa2cd5baf4d44b62a34ca9c9","_from":".","_npmVersion":"2.8.3","_nodeVersion":"1.8.1","_npmUser":{"name":"snkz","email":"abdi.dahir@outlook.com"},"maintainers":[{"name":"snkz","email":"abdi.dahir@outlook.com"}],"dist":{"shasum":"38dd04d9e55a0fa4fa2cd5baf4d44b62a34ca9c9","tarball":"https://registry.npmjs.org/mongoose-rollback/-/mongoose-rollback-1.1.4.tgz","integrity":"sha512-PTVKF5kyWmRo//HSGN6awfQInYE9hRngIwvFadPZ7HwxaPYNIpsIAsPrt8d19wISjmxiHYMMzKu0GyKYCPdgVQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDjZa9utcFsx9DHdGSReS+zNBS8SiT5ivosxAO9KVrN4AiArsU4KaNvSKH6UGGW5HXnu8jaqjfWo1LPBf6H8eH5/XQ=="}]}}},"readme":"Mongoose Rollback machine \n=========================\n\n[![Build Status](https://travis-ci.org/Snkz/mongoose-rollback.svg?branch=master)](https://travis-ci.org/Snkz/mongoose-rollback)\n\n## Overview\nMongoose-Rollback adds rollback abilities to a Model.\n\nLook up previous document revisions as well as rollback\\revert to any previous version.\n\nRequires _id field to exist (true by default) Has not been tested on custom _id fields as of yet. (i.e should be object id);\n\nA new field _version is added to the model, this can be ignored safely. An index can be set for this in the plugin options.\n\nThe \\_\\_v field is used by mongoose to help with concurrent updates, this is not altered in anyway.\n\nThe rollback model is stored in a seperate collection, the name is specified in the plugin options, \\_hist is appened to the name. It is recommended you use the same collection name as the Schema you intend to keep history for.\n\nMake sure to supply your connection name as an option (conn: mongodb://host/db} to the options field if you intend to use a seperate connection!.\n\nDELETES CASCADE! Delete your model => history is removed. I trust that you know what youre doing. \n\n#### Example Setup\n```javascript\n\nvar mongoose = require('mongoose');\nvar rollback = require('mongoose-rollback');\n\nvar Schema = mongoose.Schema;\nvar ModelSchema = new Schema({\n    name: {\n        type: String,\n        required: true\n        },\n\n    createdAt: {\n        type: Date,\n        default: Date.now\n        },\n    \n    data: {\n        type: String\n        }\n    }\n);\n\nModelSchema.plugin(rollback, {\n    index: true, // index on _version field\n    conn: 'mongodb://localhost/test', // required if connection isn't explict\n    collectionName: 'model_collection' // your collection name or custom collection\n});\n\nvar Model;\n\nif (mongoose.models.Model) {\n    Model = mongoose.model('Model');\n} else {\n    Model = mongoose.model('Model', ModelSchema, 'model_collection');\n}\n\nexports.Model = Model;\n```\n\n#### Example usage \n```javascript\ndescribe('Rollback Hell', function(done) {\n\n    it('should rollback to PREVIOUS version', function(done) {\n        var name = 'Hello';\n        var data = 'World';\n        var model = new Model({name: name, data: data});\n        model.save(function(err, model) {\n            if (err) throw (err);\n\n            model.should.have.property('_version');\n            model._version.should.be.exactly(0);\n            model.name = \"Hey\";\n            model.data = \"Yo\";\n\n            model.save(function(err, model) {\n                if (err) throw (err);\n\n                model.should.have.property('_version');\n                model._version.should.be.exactly(1);\n\n                model.rollback(0, function(err, hist) {\n                    if (err) throw (err);\n                    hist.name.should.match(name);\n                    hist.data.should.match(data);\n                    hist._version.should.equal(2);\n                    \n                    model.name.should.match(name);\n                    model.data.should.match(data);\n                    model._version.should.equal(2);\n                    done();\n                });\n            });\n        });\n        \n    });\n});\n```\n## API\n#### Methods\nThese extensions happen on <b>instances</b> of the model for convenience.\nCallbacks take the same arguments Mongoose's save does.\n```javascript\nmodel.rollback(version_num, callback(err, model))\n```\nRollsback model to version specified by version_num. Returns error if version is greater then models current version (if version supplied in model) and if version number doesnt exist. Note: This is considered an 'update' i.e the version number is incremented and the model is updated with data from a previous revision.\n```javascript\nmodel.revert(version_num, callback(err, model))\n```\nReverts model to version specified by version_num. Returns error if version is greater then models current version (if version supplied in model) and if version number doesnt exist. Note: This is a destructive update  i.e the version number is set to the supplied version  and the model is updated with data from a previous revision. History after this version number is lost.\n\n```javascript\nmodel.getVersion(version_num, callback(err, model))\n```\nReturns model at revision version_num Errors version does not exist. Creates a version 0 if neccassary;\n```javascript\nModel.currentVersion() \n```\nReturns the current version number, this is different the checking the \\_version field as it queries the history model instead. Can help with concurrent updates with outdated copies of a model.\n```javascript\nmodel.history(min_version=0, max_version=current_version, callback(err, model_array))\n```\nReturns history of model changes between specified version number. Creates a version 0 if neccassary. Pass in values (0, BIG) to get all of your history;\n\n#### Schema\nOptions for initing the plugin are pretty self-explanatory.\n```javascript\nSchema.plugin({\n    conn: seperate_mongo_location,\n    index: boolean,\n    collectionName: mongo_collection_name\n});\n\nSchema.RollbackModel\n```\nThe history model can be directly accessed from your Schema. It is added as a static variable called RollbackModel.\n\n#### Statics\nThese functions are accessed through <b>your Schema</b>. \n\n```javascript\nSchema.wipeHistory(callback);\n```\nNuke the rollback collection, there is no going back. Callback takes the same arguments mongoose's remove does.\n\n```javascript\nSchema.initHistory(id, callback(err, model_array))\n```\nFor models that have been inserted outside of mongoose's save methods. This will save it without updating the version number.\nThis is also done on calls to .getVersion(0, callback); and .history(0,max, callback); internally on existing models that have no history. Do this only if you care about preserving the current version of the model. Future updates will be recorded just fine with or without this call to init. \n\n### Coming Soon!\nHandle concurrency, (see below)\n\nMark models to prevent history updates (can be toggled on the fly).\nAllow for storage of diffs along with full model. \nRemove requirement to add in collection name removed.\n\n## About concurrency\nConcurrent saves currently work like they do in mongo, latest update wins. Initial commits to the hist model are also kind of iffy cause of \\_id collisions. Avoid initing history for an existing model concurrently.\n\nRollbacks have not been tested concurrently, however they are expected to work like save. Last rollback is the one that will happen. Confirm version value after a rollback incase you expect to do such a thing often.\n\nThe following three ops CAN create new hist models:\n    save\n    getVersion\n    history\n\nTry not to do anything concurrently on models that haven't been init'd through mongoose's save. Updates after are A-OK.\n\nReverts however are dangerous, I will not make any promises. I will document expected behaviour after more testing. Either way, it is best to not revert willy-nilly. That should be a privileged operation!\n\n## About Mongoose\nMongoose does not hook into findByIdUpdate/remove mongo methods. Those bypass any middleware by design, including this rollback system. In order to keep history correctly make sure to use this pattern for updates instead.\n\n```javascript\nModel.find({field: value}, function (err, model) {\n    model.somefield = somevalue;\n    model.save(function (err, updatedModel) {\n        // more code\n    });\n});\n```\nLikewise, deletes should also be done through mongoose. Make sure to do one of the following:\n\n```javescript\nModel.remove({_id: id}).exec(function(err, num_removed) {\n    // more code\n});\n\n// OR on a model instance\n\nmodel.remove(function(err, model) {\n    // more code\n});\n```\n\nThey're other mongoose ways to update/delete, they should work fine. Incase an issue does come up, try the above and report it please.\n\nFinally, this is ready to use but being updated very rapidly. Please open issues, report bugs etc and I will get to them.\n","maintainers":[{"name":"snkz","email":"abdi.dahir@outlook.com"}],"time":{"modified":"2022-06-20T07:43:54.894Z","created":"2014-11-04T23:20:12.625Z","1.0.0":"2014-11-04T23:20:12.625Z","1.0.1":"2014-11-05T00:06:36.627Z","1.0.2":"2014-11-05T06:35:17.753Z","1.0.3":"2014-11-06T02:11:29.146Z","1.0.4":"2014-11-06T02:23:29.399Z","1.0.5":"2014-11-06T21:19:36.741Z","1.1.0":"2014-11-08T23:37:10.674Z","1.1.1":"2014-11-11T04:32:01.203Z","1.1.2":"2014-11-13T01:33:32.340Z","1.1.3":"2014-11-23T03:22:16.934Z","1.1.4":"2015-06-11T17:51:40.341Z"},"homepage":"https://github.com/Snkz/mongoose-rollback","keywords":["mongo","mongodb","mongoose","history","revisions","rollback"],"repository":{"type":"git","url":"git+ssh://git@github.com/Snkz/mongoose-rollback.git"},"author":{"name":"Abdi Dahir"},"bugs":{"url":"https://github.com/Snkz/mongoose-rollback/issues"},"license":"ISC","readmeFilename":"README.md","users":{"mgenev":true}}