{"id":14975657,"url":"https://github.com/stennettm/historical","last_synced_at":"2025-10-27T14:31:05.656Z","repository":{"id":16963483,"uuid":"19725941","full_name":"stennettm/historical","owner":"stennettm","description":"A Mongoose plugin that archives document diffs and manages document history.","archived":false,"fork":false,"pushed_at":"2023-01-11T00:56:04.000Z","size":125,"stargazers_count":33,"open_issues_count":7,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T06:11:46.535Z","etag":null,"topics":["historical-documents","history","mongoose","mongoose-plugin","snapshot"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stennettm.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":"2014-05-13T04:35:44.000Z","updated_at":"2024-04-17T04:43:14.000Z","dependencies_parsed_at":"2023-01-13T19:05:57.554Z","dependency_job_id":null,"html_url":"https://github.com/stennettm/historical","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stennettm%2Fhistorical","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stennettm%2Fhistorical/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stennettm%2Fhistorical/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stennettm%2Fhistorical/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stennettm","download_url":"https://codeload.github.com/stennettm/historical/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238508755,"owners_count":19484198,"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":["historical-documents","history","mongoose","mongoose-plugin","snapshot"],"created_at":"2024-09-24T13:52:21.030Z","updated_at":"2025-10-27T14:31:05.305Z","avatar_url":"https://github.com/stennettm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://secure.travis-ci.org/stennettm/historical.png)](http://travis-ci.org/stennettm/historical)\nHistorical\n==========\n\nA Mongoose plugin that archives document diffs and manages document history.\n\nHistorical requires a primary key (typically `_id`) to be present in your schema.\n\nInstallation\n------------\n\n`npm install historical@^2.0.0`\n\nGetting Started\n---------------\n\nAttach the plugin to your schema with any of these optional configuration parameters:\n\n- `name`: Provide a collection name. Defaults to `\u003ccollection\u003e_historicals`.\n- `connection`: Provide a mongoose connection for the historical collection. Defaults to your schema's connection.\n- `primaryKeyName`: Provide your schema's primary key name. Defaults to `_id`.\n- `primaryKeyType`: Provide your schema's primary key type. Defaults to your schema's primary key field configuration.\n- `ignore`: An array of field names to ignore. Fields included in this list will not be stored in history.\n\n```javascript\nvar mongoose  = require('mongoose'),\nExampleSchema = new mongoose.Schema({\n    myField: String,\n    ignoredField: String,\n    anotherIgnoredField: String\n});\n\nExampleSchema.plugin(require('historical'), {\n    connection: mongoose.createConnection('mongodb://localhost/example'),\n    name: null,\n    primaryKeyName: null,\n    primaryKeyType: null,\n    ignore: ['ignoredField', 'anotherIgnoredField']\n});\n```\n\nDocument #historicalDetails()\n---------------------------------------------------------\n\nList historical documents up to the given date for a document.\n\n```javascript\nmyDocument.historicalDetails(new Date('2010-08-17T12:09:36'), function(e, objs){\n   //the list of historical changes for my document\n   console.log(objs);\n});\n```\n\nDocument #historicalRestore()\n---------------------------------------------------------\n\nReturns a document as it was at the given date.\n\n```javascript\nmyDocument.historicalRestore(new Date('2010-08-17T12:09:36'), function(e, obj){\n   //my document as it was in 2010\n   //or null, if it either had not yet been created or was deleted before this time\n   if(obj) {\n      obj.save();\n   }\n});\n```\n\nDocument #historicalTrim()\n------------------------------------------------------\n\nCreates a new historical document by flattening history up to the given date, and deletes the touched historical documents.\nUseful for pruning or establishing a maximum history retention period.\n\n```javascript\nmyDocument.historicalTrim(new Date('2010-08-17T12:09:36'), function(e, obj){\n   //any history before this time has been flattened into one historical document\n   //my document as it was provided\n   console.log(obj);\n});\n```\n\nDocument #historicalSnapshot()\n-----------------------------------------------\n\nTake a complete and current snapshot of my document and store it in history.\nUnmodified documents only.\n\n```javascript\nmyDocument.historicalSnapshot(function(e, obj){\n   //my document as it was provided\n   console.log(obj);\n});\n```\n\nDocument #historicalClear()\n--------------------------------------------\n\nClear all history for my document and take a snapshot.\nUnmodified documents only.\n\n```javascript\nmyDocument.historicalClear(function(e, obj){\n   //my document as it was provided\n   console.log(obj);\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstennettm%2Fhistorical","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstennettm%2Fhistorical","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstennettm%2Fhistorical/lists"}