{"id":21521074,"url":"https://github.com/weisjohn/mongoose-prime","last_synced_at":"2025-03-17T17:16:39.315Z","repository":{"id":12656640,"uuid":"15328398","full_name":"weisjohn/mongoose-prime","owner":"weisjohn","description":"Prime a mongoose model with default data.","archived":false,"fork":false,"pushed_at":"2016-03-17T18:57:32.000Z","size":12,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-24T08:50:17.928Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/mongoose-prime","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"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":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-20T02:47:13.000Z","updated_at":"2024-06-22T02:57:32.000Z","dependencies_parsed_at":"2022-09-10T04:26:17.253Z","dependency_job_id":null,"html_url":"https://github.com/weisjohn/mongoose-prime","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-prime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weisjohn%2Fmongoose-prime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weisjohn%2Fmongoose-prime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weisjohn%2Fmongoose-prime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weisjohn","download_url":"https://codeload.github.com/weisjohn/mongoose-prime/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:40.691Z","updated_at":"2025-03-17T17:16:39.288Z","avatar_url":"https://github.com/weisjohn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mongoose-prime\n\nprime a mongoose model with data\n\n### usage\n\n```javascript\n// mongoose is connection and `users` is already registered\nvar mp = require('mongoose-prime')\n  , users = mongoose.model('users')\n  , data = require('./data/users')\n  ;\n\nmp(users, data, function(err, results) {\n    Object.keys(results).forEach(function(key) {\n        console.log(results[key] + \" user \" + key);\n    });\n});\n```\n\n\n### api\n\n#### `mp(model, data, [validate], [callback])`\n\n - `model` - reference to the mongoose model\n - `data` - an object or array of objects\n - `validate` - optional boolean to disable schema validation (default: `null`)\n - `callback` - optional `function(err, results) {}`\n\n`callback` receives a `results` object of with three numbers: `added`, `failed`, `skipped` and a `records` array, containing the inserted records.\n\n`validate` indicates whether schema validation should occur before inserting. For example, object reference validators which ensure the referenced document exists may prevent data from being loaded (i.e. cylical dependencies). To prevent this, invoke with the value of `false` to temporarily suspend the validators. After loading the data, the schema validation will be set to it's previous value. If no value is specified, `mongoose-prime` will not modify the model's validation settings. (cf. [`#validateBeforeSave`](http://mongoosejs.com/docs/guide.html#validateBeforeSave))\n\n### integration\n\n`mongoose-prime` plays nicely with [`mongoose-deleted`](https://www.npmjs.com/package/mongoose-deleted).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweisjohn%2Fmongoose-prime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweisjohn%2Fmongoose-prime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweisjohn%2Fmongoose-prime/lists"}