{"id":14975659,"url":"https://github.com/aldaviva/mongoose-moment","last_synced_at":"2025-10-27T14:31:11.092Z","repository":{"id":15504394,"uuid":"18238426","full_name":"Aldaviva/mongoose-moment","owner":"Aldaviva","description":"🕰 Store Moment dates in Mongo using Mongoose internally as millisecond timestamps.","archived":false,"fork":false,"pushed_at":"2017-02-05T07:43:54.000Z","size":20,"stargazers_count":9,"open_issues_count":1,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-11T12:20:11.474Z","etag":null,"topics":["momentjs","mongoose","mongoose-plugin","orm","timestamps"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/mongoose-moment","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Aldaviva.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-03-29T09:42:16.000Z","updated_at":"2024-01-18T15:38:06.000Z","dependencies_parsed_at":"2022-07-28T20:29:48.140Z","dependency_job_id":null,"html_url":"https://github.com/Aldaviva/mongoose-moment","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aldaviva%2Fmongoose-moment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aldaviva%2Fmongoose-moment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aldaviva%2Fmongoose-moment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aldaviva%2Fmongoose-moment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aldaviva","download_url":"https://codeload.github.com/Aldaviva/mongoose-moment/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219861083,"owners_count":16556007,"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":["momentjs","mongoose","mongoose-plugin","orm","timestamps"],"created_at":"2024-09-24T13:52:21.183Z","updated_at":"2025-10-27T14:31:05.775Z","avatar_url":"https://github.com/Aldaviva.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"mongoose-moment\n===============\n\nStore [Moment](http://momentjs.com/docs) dates in [Mongo](http://docs.mongodb.org/manual/) using [Mongoose](http://mongoosejs.com/docs/index.html) internally as millisecond timestamps.\n\n## Installing\n\n\t$ npm install mongoose moment mongoose-moment\n\t\n```javascript\nvar mongoose = require('mongoose')\nrequire('mongoose-moment')(mongoose);\n```\n\n## Configuration\n\nUse the new SchemaType `'Moment'` in your schema definitions:\n```javascript\nvar mySchema = new mongoose.Schema({\n\tcreated: 'Moment'\n});\nvar MyModel = new mongoose.Model('MyModel', mySchema);\n```\n\n## Usage\n\n### Writing models\n```javascript\nvar Moment = require('moment');\nvar myModel = new MyModel({ created: new Moment() });\nmyModel.save();\n```\n\n### Reading models\n```javascript\nvar myModel = MyModel.findById('123', function(err, doc){\n\tconsole.log(doc.created.format());\n});\n```\n\n### Querying for models\nMongoose doesn't transform query values according to schemas, so you'll have to do it yourself.\nInternally, Moment values are stored in the database as the number of milliseconds since the Unix epoch.\nTo find a document using a Moment field, use a query like\n```javascript\nMyModel.find({ created: new Moment('2014-03-29').valueOf() }, function(err, docs) {});\n```\n\n## Thanks\n\n* Aaron Heckmann's [mongoose-regexp](https://github.com/aheckmann/mongoose-regexp)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faldaviva%2Fmongoose-moment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faldaviva%2Fmongoose-moment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faldaviva%2Fmongoose-moment/lists"}