{"id":16473211,"url":"https://github.com/saintedlama/mongoose-version","last_synced_at":"2025-04-06T18:14:02.417Z","repository":{"id":57302347,"uuid":"7682056","full_name":"saintedlama/mongoose-version","owner":"saintedlama","description":"Mongoose plugin to save document data versions. Documents are saved to a \"versioned\" document collection before saving original documents and kept for later use.","archived":false,"fork":false,"pushed_at":"2023-01-10T08:19:08.000Z","size":68,"stargazers_count":144,"open_issues_count":18,"forks_count":29,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-30T17:09:59.776Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saintedlama.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-01-18T07:00:11.000Z","updated_at":"2025-01-30T06:24:49.000Z","dependencies_parsed_at":"2023-02-08T17:46:10.157Z","dependency_job_id":null,"html_url":"https://github.com/saintedlama/mongoose-version","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saintedlama%2Fmongoose-version","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saintedlama%2Fmongoose-version/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saintedlama%2Fmongoose-version/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saintedlama%2Fmongoose-version/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saintedlama","download_url":"https://codeload.github.com/saintedlama/mongoose-version/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247526761,"owners_count":20953143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T12:25:49.611Z","updated_at":"2025-04-06T18:14:02.399Z","avatar_url":"https://github.com/saintedlama.png","language":"JavaScript","funding_links":[],"categories":["⏱ Timestamps \u0026 Audit"],"sub_categories":[],"readme":"# Mongoose Version \n\n[![Build Status](https://travis-ci.org/saintedlama/mongoose-version.png?branch=master)](https://travis-ci.org/saintedlama/mongoose-version) [![Coverage Status](https://coveralls.io/repos/saintedlama/mongoose-version/badge.png?branch=master)](https://coveralls.io/r/saintedlama/mongoose-version?branch=master)\n[![mongoose-version analyzed by Codellama.io](https://app.codellama.io/api/badges/5a0439261b4c363a0f9427d5/701ecb565450af80551f9cbfe90e8294)](https://app.codellama.io/repositories/5a0439261b4c363a0f9427d5)\n\nMongoose Version is a mongoose plugin to save document data versions. Documents are saved to a \"versioned\" document collection before saving\noriginal documents and kept for later use.\n\n## Installation\n\n    $ npm install mongoose-version\n\n## Usage\nTo use mongoose-version for an existing mongoose schema you'll have to require and plugin mongoose-version into the \nexisting schema.\n\nThe following schema definition defines a \"Page\" schema, and uses mongoose-version plugin with default options\n\n```js\nvar mongoose = require('mongoose');\nvar Schema = mongoose.Schema;\nvar version = require('mongoose-version');\n\nvar Page = new Schema({\n  title : { type : String, required : true},\n  content : { type : String, required : true },\n  path : { type : String, required : true},\n  tags : [String],\n\n  lastModified : Date,\n  created : Date\n});\n\nPage.plugin(version);\n```\n\nMongoose-version will define a schema that has a refId field pointing to the original model and a version array containing\ncloned copies of the versioned model.\n\nMongoose-version will add a static field to Page, that is \"VersionedModel\" that can be used to access the versioned\nmodel of page, for example for querying old versions of a document.\n\n## Option keys and defaults\n* collection: name of the collection to persist versions to. The default is 'versions'. You should supply this option if you're using mongoose-version on more than one schema.\n* suppressVersionIncrement: mongoose-version will not increment the version of the saved model before saving the model by default. To turn on auto version increment set this option to false. Default: `true`\n* suppressRefIdIndex: mongoose-version will not index the refId field by default. To turn on indexing on refId set this option to false. Default: `true`\n* strategy: mongoose-version allows versioned document to be saved as multiple documents in a collection or in a single document in a version array. In case you want to save documents in an array specify `array` strategy, for storing versioned documents in multiple documents specify `collection` strategy. Default `array`.\n* maxVersions: Only valid for `array` strategy. Specifies how many historic versions of a document should be kept. Defaults to `Number.MAX_VALUE`.\n* mongoose: Pass a mongoose instance to work with\n* removeVersions: Removes versions when origin document is removed. Defaults to `false`\n* ignorePaths: Defines an array of document field names that do not trigger a new version to be created when this field was changed. Only working with array strategy (default strategy). Defaults to `[]`.\n* refIdType: The type of the `_id` field used in your document. Will be used to set the type of the refId. Defaults to `ObjectId`.\n* Options are passed to a newly created mongoose schemas as settings, so you may use any [option supported by mongoose](http://mongoosejs.com/docs/guide.html#options)\n\nIn case you only want to specify the collection name, you can pass a string instance to options that is taken as collection name. Options may be passed as follows:\n\n```js\nPage.plugin(version, { collection: 'Page__versions' });\n```\n\n## Misc\n\n### Debug Messages\n\nMongoose-version uses the [debug module](https://github.com/visionmedia/debug) for debug messages. You can enable mongoose-version debug logs by setting the\n`DEBUG` environment variable to `mongoose:version`.\n\n    DEBUG=mongoose:version\n\non Windows use\n\n    SET DEBUG=mongoose:version\n\nDebug messages are logged if a version was persisted to mongodb or a version was removed from mongodb.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaintedlama%2Fmongoose-version","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaintedlama%2Fmongoose-version","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaintedlama%2Fmongoose-version/lists"}