{"id":21521091,"url":"https://github.com/weisjohn/mongoose-history-log","last_synced_at":"2025-03-17T17:16:40.628Z","repository":{"id":35282527,"uuid":"39543410","full_name":"weisjohn/mongoose-history-log","owner":"weisjohn","description":"add a collection of events to a schema","archived":false,"fork":false,"pushed_at":"2015-07-23T03:48:14.000Z","size":132,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-29T15:41:15.567Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/mongoose-history-log","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/weisjohn.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":"2015-07-23T03:20:35.000Z","updated_at":"2024-06-22T02:57:47.000Z","dependencies_parsed_at":"2022-09-16T22:02:29.774Z","dependency_job_id":null,"html_url":"https://github.com/weisjohn/mongoose-history-log","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weisjohn%2Fmongoose-history-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weisjohn%2Fmongoose-history-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weisjohn%2Fmongoose-history-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weisjohn%2Fmongoose-history-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weisjohn","download_url":"https://codeload.github.com/weisjohn/mongoose-history-log/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244075649,"owners_count":20393980,"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-11-24T01:05:44.468Z","updated_at":"2025-03-17T17:16:40.606Z","avatar_url":"https://github.com/weisjohn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mongoose-history-log\n\nadd a collection of events to a schema\n\n\n### usage\n\nschema setup:\n\n```javascript\nvar mongoose = require('mongoose');\nvar mhl = require('mongoose-history-log');\n\nvar schema = new mongoose.Schema({ name: String });\n\nmhl(schema);\n```\n\nThis adds a `history` property to the schema which is an array of objects:\n\n```javascript\n[{\n    time: { type: Date, default: Date.now },\n    status: String,\n    meta: {}\n}]\n```\n\nThe `meta` property allows you to attach an arbitrartily complex object onto the `history` element. When saving the document for the first time, it will automatically add an `{ status : \"created\" }` record with the current time.\n\nAdding other events:\n\n```javascript\nvar user = mongoosel.model('user');\n\nuser.findOne({ email : 'test@example.net' }, function(err, doc) {\n    doc.history.push({ status: \"foo\" });\n    doc.save();\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweisjohn%2Fmongoose-history-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweisjohn%2Fmongoose-history-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweisjohn%2Fmongoose-history-log/lists"}