{"id":14975655,"url":"https://github.com/james075/mongoose-createdat-updatedat","last_synced_at":"2025-10-27T14:31:08.159Z","repository":{"id":36178491,"uuid":"40482618","full_name":"james075/mongoose-createdat-updatedat","owner":"james075","description":"Mongoose plugin - timestamp handler","archived":false,"fork":false,"pushed_at":"2023-01-11T04:05:51.000Z","size":199,"stargazers_count":12,"open_issues_count":6,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T06:11:40.902Z","etag":null,"topics":["mongoose","mongoose-createdat-updatedat","mongoose-plugin","mongoose-schema"],"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/james075.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-10T12:59:12.000Z","updated_at":"2023-11-03T09:47:13.000Z","dependencies_parsed_at":"2023-01-16T23:45:57.671Z","dependency_job_id":null,"html_url":"https://github.com/james075/mongoose-createdat-updatedat","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james075%2Fmongoose-createdat-updatedat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james075%2Fmongoose-createdat-updatedat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james075%2Fmongoose-createdat-updatedat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james075%2Fmongoose-createdat-updatedat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/james075","download_url":"https://codeload.github.com/james075/mongoose-createdat-updatedat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238508738,"owners_count":19484195,"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":["mongoose","mongoose-createdat-updatedat","mongoose-plugin","mongoose-schema"],"created_at":"2024-09-24T13:52:20.787Z","updated_at":"2025-10-27T14:31:02.799Z","avatar_url":"https://github.com/james075.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mongoose-createdAt-updatedAt\n\nA mongoose plugin that adds createdAt and updatedAt fields to subscribed models in order to avoid redundancy.\n\nNow supporting query-based updates like update() or findOneAndUpdate().\n\n### Install via npm:\n\n```bash\n$\u003e npm install mongoose-createdat-updatedat --save\n```\n\n### Usage:\n\n```js\nvar plugin = require('mongoose-createdat-updatedat');\nvar User = new Schema({ ... });\nUser.plugin(plugin);\n```\n\nOptionally, you can pass an options object to set the name of the fields, or to disable certain fields.\n\nAnother example:\n\n```js\nvar plugin = require('mongoose-createdat-updatedat');\nvar User = new Schema({ ... });\nvar options = {\n  createdAt: 'created_at',\n  updatedAt: null\n}\nUser.plugin(plugin, options);\n```\n\nHere, the createdAt field will be named `created_at`, and the updatedAt field will be disabled.\n\n### Options:\n\n##### createdAt\nType: `String`  \nDefault: `createdAt`\n\nName of the createdAt field. Set to null to disable the field\n\n##### updatedAt\nType: `String`  \nDefault: `updatedAt`\n\nName of the updatedAt field. Set to null to disable the field\n\n### Test:\n\n```bash\n$\u003e npm test\n$\u003e\n  CreatedAt and UpdatedAt support\n    ✓ should has \"James\" as firstname\n    ✓ should save user without error (237ms)\n    ✓ should createdAt and updatedAt have equal values\n    ✓ should update user lastname to \"Heng\" without error\n    ✓ updatedAt should be more recent than createdAt\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjames075%2Fmongoose-createdat-updatedat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjames075%2Fmongoose-createdat-updatedat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjames075%2Fmongoose-createdat-updatedat/lists"}