{"_id":"mongoose-dbref","_rev":"36-2af1ad5c0c8b25515e571bae5fe53913","name":"mongoose-dbref","description":"Plugin support for DBRef in Mongoose","dist-tags":{"latest":"0.0.4"},"versions":{"0.0.1":{"name":"mongoose-dbref","description":"Plugin support for DBRef in Mongoose","version":"0.0.1","author":{"name":"Stuart Hudson","email":"goulash1971@yahoo.com"},"keywords":["mongodb","mongoose","mongo","types","dbref"],"homepage":"https://github.com/goulash1971/mongoose-dbref","contributors":[{"name":"Stuart Hudson","email":"goulash1971@yahoo.com","url":"http://goulash1971.com/"}],"dependencies":{"mongoose":">= 1.0.16"},"scripts":{"test":"make test"},"directories":{"lib":"lib/","test":"tests/"},"main":"./index","engines":{"node":">= 0.1.101"},"repository":{"type":"git","url":"git://github.com/goulash1971/mongoose-dbref.git"},"licenses":[{"type":"The MIT License","url":"http://www.opensource.org/licenses/mit-license.php"}],"devDependencies":{},"_id":"mongoose-dbref@0.0.1","_engineSupported":true,"_npmVersion":"1.0.3","_nodeVersion":"v0.5.0-pre","_defaultsLoaded":true,"dist":{"shasum":"86c22610ead6d001af538d48624c3806db498f33","tarball":"https://registry.npmjs.org/mongoose-dbref/-/mongoose-dbref-0.0.1.tgz","integrity":"sha512-zkndZbwQO7/XfmwRZMm+sXmdbE1lpbfufQypvxJACBbrL3kB2n0KE3Uqj33gRtSBj9emgKYCdx/2AXZRcKuUGw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDaDf8+B8CuxOUrEyQtXjbmPAPSN6dlEJmoVYaAfw77cgIgfW2nO68RGWux6keXLwEq7zi3S8hDAkuuJD1T4NS9h04="}]}},"0.0.2":{"name":"mongoose-dbref","description":"Plugin support for DBRef in Mongoose","version":"0.0.2","author":{"name":"Stuart Hudson","email":"goulash1971@yahoo.com"},"keywords":["mongodb","mongoose","mongo","types","dbref"],"homepage":"https://github.com/goulash1971/mongoose-dbref","contributors":[{"name":"Stuart Hudson","email":"goulash1971@yahoo.com","url":"http://goulash1971.com/"}],"dependencies":{"mongoose":">= 1.0.16"},"scripts":{"test":"make test"},"directories":{"lib":"lib/","test":"tests/"},"main":"./index","engines":{"node":">= 0.1.101"},"repository":{"type":"git","url":"git://github.com/goulash1971/mongoose-dbref.git"},"licenses":[{"type":"The MIT License","url":"http://www.opensource.org/licenses/mit-license.php"}],"devDependencies":{},"_id":"mongoose-dbref@0.0.2","_engineSupported":true,"_npmVersion":"1.0.3","_nodeVersion":"v0.4.9","_defaultsLoaded":true,"dist":{"shasum":"70f360130eaef000e435334bfc7307e6b9c34ae1","tarball":"https://registry.npmjs.org/mongoose-dbref/-/mongoose-dbref-0.0.2.tgz","integrity":"sha512-oH9mcDWfPB2vbXdKufVovoks14IfuIdED19J9Xc0kNLd15i9VMyDrxJFXkMJcZ1ah5pnDku3s2x+aARQQZEg5Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC0SXgykbuX0zGQzmULorkzUewFTqV0mal4seHiDxTNIgIhANFqcRD+HYaOfQogzR7H1xKM8OtCuontHtQGqr70KcyT"}]}},"0.0.3":{"name":"mongoose-dbref","description":"Plugin support for DBRef in Mongoose","version":"0.0.3","author":{"name":"Stuart Hudson","email":"goulash1971@yahoo.com"},"keywords":["mongodb","mongoose","mongo","types","dbref"],"homepage":"https://github.com/goulash1971/mongoose-dbref","contributors":[{"name":"Stuart Hudson","email":"goulash1971@yahoo.com","url":"http://goulash1971.com/"}],"dependencies":{"mongoose":">= 1.0.16"},"scripts":{"test":"make test"},"directories":{"lib":"lib/","test":"tests/"},"main":"./index","engines":{"node":">= 0.1.101"},"repository":{"type":"git","url":"git://github.com/goulash1971/mongoose-dbref.git"},"licenses":[{"type":"The MIT License","url":"http://www.opensource.org/licenses/mit-license.php"}],"devDependencies":{"should":"^11.2.1"},"gitHead":"eec330319f3eb5b455b2558276e6db9766cc0419","bugs":{"url":"https://github.com/goulash1971/mongoose-dbref/issues"},"_id":"mongoose-dbref@0.0.3","_npmVersion":"5.3.0","_nodeVersion":"8.2.1","_npmUser":{"name":"goulash1971","email":"goulash1971@gmail.com"},"dist":{"integrity":"sha512-rkrMSCtjalUis9xXup5rzvVtT6ktcxWG7M6VVSWbeBnkwDdj6nE/RaDPqHP1aTXPgnO16C0g+L5XRT8wGL9rUQ==","shasum":"28b40f9fbec516c77f459e9a80d1269a2d109247","tarball":"https://registry.npmjs.org/mongoose-dbref/-/mongoose-dbref-0.0.3.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDcrk2ITHSTrbNdq+9KTlzTUM0wEpkRyFxnR11WVYN1QAIgFJKUfb5TRRQdisb4HCfgffOfu3YLZjAfsdLLgCdK6rs="}]},"maintainers":[{"name":"goulash1971","email":"goulash1971@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mongoose-dbref-0.0.3.tgz_1501386009297_0.73672915995121"},"deprecated":"Installation issue"},"0.0.4":{"name":"mongoose-dbref","description":"Plugin support for DBRef in Mongoose","version":"0.0.4","author":{"name":"Stuart Hudson","email":"goulash1971@yahoo.com"},"keywords":["mongodb","mongoose","mongo","types","dbref"],"homepage":"https://github.com/goulash1971/mongoose-dbref","contributors":[{"name":"Stuart Hudson","email":"goulash1971@yahoo.com","url":"http://goulash1971.com/"}],"dependencies":{"mongoose":">= 1.0.16"},"scripts":{"test":"make test"},"directories":{"lib":"lib/","test":"tests/"},"main":"./index","engines":{"node":">= 0.1.101"},"repository":{"type":"git","url":"git://github.com/goulash1971/mongoose-dbref.git"},"licenses":[{"type":"The MIT License","url":"http://www.opensource.org/licenses/mit-license.php"}],"gitHead":"93bbb2fd74aa8eeb4f82122223003f28098d0588","bugs":{"url":"https://github.com/goulash1971/mongoose-dbref/issues"},"_id":"mongoose-dbref@0.0.4","_npmVersion":"5.3.0","_nodeVersion":"8.2.1","_npmUser":{"name":"goulash1971","email":"goulash1971@gmail.com"},"dist":{"integrity":"sha512-tzaiiTdnMhUqm7EvfWeYdowTztMk4wMsS07QjK1TOw+xwyKljrjAm3ZFd4t3CeUBPeC/K1MTdamp6JFdMS6Ntg==","shasum":"5b8f76339b441c6060a6ee63bc2962ed6a5e23e0","tarball":"https://registry.npmjs.org/mongoose-dbref/-/mongoose-dbref-0.0.4.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAL3Vgcg5zuxvwOlcmb2qL48hwJJItjg4kTaswqAMlOMAiBy9aj3U96TJaZ4N8g1TJRmUOyzURwBXqBGdPw35tcewg=="}]},"maintainers":[{"name":"goulash1971","email":"goulash1971@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mongoose-dbref-0.0.4.tgz_1501388990539_0.2414469642098993"}}},"maintainers":[{"email":"goulash1971@gmail.com","name":"goulash1971"}],"time":{"modified":"2022-06-20T07:02:30.380Z","created":"2011-06-08T04:47:02.818Z","0.0.1":"2011-06-08T04:47:04.096Z","0.0.2":"2011-06-16T03:06:45.993Z","0.0.3":"2017-07-30T03:40:09.425Z","0.0.4":"2017-07-30T04:29:50.616Z"},"author":{"name":"Stuart Hudson","email":"goulash1971@yahoo.com"},"repository":{"type":"git","url":"git://github.com/goulash1971/mongoose-dbref.git"},"readme":"mongoose-dbref - Plugin support for DBRef in Mongoose \n==============\n\n### Overview\n\nMongoose-DBRef is an extension for Mongoose that exposes the DBRef type from the the `node-mongodb-native`\ndriver as a top level type in the Mongoose ORM and provides some utilities, plugins and patches that allow \nDBRef instances to be dereferenced from the models.\n\n#### Extension contents\n\nThe extension provides the following types:\n\n- `DBRef` : this is the schema type that can be used for database references\n\nThe extension provides the following plugins:\n\n- `resolveDBRefs` : used to create getter/setter methods that resolve DBRefs\n- `dbrefHooks` : adds hooks to schema and model for DBRefs\n\nThe extension includes the following monkey-patches:\n\n- `dbref.fetch` : used to resolve the dbref against a supplied connection\n\nThe extension provides the following utilities:\n\n- `fetch` : fetches the object referenced by a DBRef value\n\n### Installation\n\tnpm install mongoose-dbref\n\n### Setup\nTo install all of the types, plugins, patches and utilities provided by the extension into a Mongoose \ninstance:\n\n\tvar mongoose = require(\"mongoose\");\n\t   \n\t// Create a connection to your database\n\tvar db = mongoose.createConnection(\"mongodb://localhost/sampledb\");\n\t\n\t// Access the mongoose-dbref module and install everything\n\tvar dbref = require(\"mongoose-dbref\");\n\tvar utils = dbref.utils\n\t\n\t// Install the types, plugins and monkey patches\n\tvar loaded = dbref.install(mongoose);\n\nThe `loaded` value returned contains 2 properties:\n\n- `loaded.types` : the join types that were loaded\n- `loaded.plugins` : the extension plugins that were loaded\n\nIf you want to control what is installed, you can either install types/plugins/patches separately (see below)\nor pass in a second argument to the `install` function.\n\nIf this second argument is a `Function` then it will be used as a filter when installing the types, plugins and\npatches.  If it is an `Object` then the `types` property (either a filter `Function` or list of type names) is used\nwhen loading the types, the `plugins` property (either a filter `Function` or list of plugin names) is used when\ninstalling the plugins and the `patches` property (either a filter `Function` or list of patch names) is used when\ninstalling the patches.\n\n#### Loading Types Only\n\nTo just install the types provided by the extension:\n\n\tvar mongoose = require(\"mongoose\");\n   \n\t// Create a connection to your database\n\tvar db = mongoose.createConnection(\"mongodb://localhost/sampledb\");\n\n\t// Access the mongoose-dbref module\n\tvar dbref = require(\"mongoose-dbref\");\n\tvar utils = dbref.utils\n\t\n\t// Install the plugins\n\tvar loaded = dbref.loadTypes(mongoose);\n\nThe `loaded` value returned contains the types that were loaded, keyed by the name of each type \nloaded.\n\nIf you just want to load a specific list of types, or want to filter the types loaded then use one\nof the following signatures with the `loadTypes()` function:\n\n   - `loadTypes(mongoose, 'dbref')` : just loads the `dbref` type\n   - `loadTypes(mongoose, function(type) { return type.slice(1,2) === 'db'; })` : loads types starting with `db`\n\n#### Installing Plugins Only\n\nTo just install the plugins provided by the extension:\n\n\tvar mongoose = require(\"mongoose\");\n\t   \n\t// Create a connection to your database\n\tvar db = mongoose.createConnection(\"mongodb://localhost/sampledb\");\n\t\n\t// Access the mongoose-dbref module\n\tvar dbref = require(\"mongoose-dbref\");\n\tvar utils = dbref.utils\n\t\n\t// Install the plugins\n\tvar loaded = dbref.installPlugins(mongoose);\n\nThe `loaded` value returned contains the plugins that were loaded, keyed by the name of each plugin \nloaded.\n\nIf you just want to install a specific list of plugins, or want to filter the plugins loaded then use one\nof the following signatures with the `installPlugins()` function:\n\n   - `installPlugins(mongoose, 'resolveDBRefs')` : just install the `resolveDBRef` plugin\n   - `installPlugins(mongoose, function(plugin) { return plugin.slice(1,2) === 'db'; })` : installs plugins starting with `db`\n\n#### Installing Patches Only\n\nTo just install the patches provided by the extension (all patches, named named patches or filtered patches):\n\n\tvar mongoose = require(\"mongoose\");\n\t   \n\t// Create a connection to your database\n\tvar db = mongoose.createConnection(\"mongodb://localhost/sampledb\");\n\t\n\t// Access the mongoose-dbref module and the utilities\n\tvar dbref = require(\"mongoose-dbref\");\n\tvar utils = dbref.utils;\n\t\n\t// Install the monkey patches\n\tdbref.installPatches(mongoose);\n\nIf you just want to install a specific list of patches, or want to filter the patches loaded then use one\nof the following signatures with the `installPatches()` function:\n\n   - `installPatches(mongoose, 'fetch')` : just install the `fetch` patch\n   - `installPatches(mongoose, function(patch) { return patch.slice(1,2) === 'db'; })` : installs patch starting with `db`\n\n### Using the types\nOnce you have loaded the types, or installed the whole extension, you can begin to use them.\n\n#### Type: `DBRef`\nThe `DBRef` type is a top-level schema type that can be used to identfied a field as holding\na MongoDb database reference.  You use the type as you would any other standard type.\n\n\tvar DBRef = mongoose.SchemaTypes.DBRef;\n\t\n\tvar LineItemSchema = new Schema({\n\t\torder: DBRef,\n\t \tdescription: String,\n\t\tcost: Number\n\t});\n\t\n\tvar OrderSchema = new Schema({\n\t\tpoNumber: String,\n\t\tlineItems: [DBRef]\n\t});\n\nThis will create two schema - `OrderSchema` that has a field (`lineItems`) which can hold \nmultiple references, and `LineItemSchema` that has a field `order` with a single reference.\n\nAll of the *standard* options (`required`, `index` etc) can be applied to these fields.\n\n### Using the plugins\nOnce you have installed the plugins, or installed the whole extension, you can begin to use them.\n\n#### Plugin: `resolveDBRefs`\nThe `resolveDBRefs` plugin can be used to be used to automatically install *getter* and *setter*\nmethods for fields where a `resolve` option has been set.\n\nThese methods will map DBRef values to/from objects via the database connection of the owning \nmodel.\n\nFor example:\n\n\tvar LineItemSchema = new Schema({\n\t\torder: {type: DBRef, resolve: true},\n\t \tdescription: String,\n\t\tcost: Number\n\t});\n\nThis will create two methods:\n\n- `getOrder(callback)` - this will asynchronously resolve the `DBRef` value in the `order` field\n\n- `setOrder(value)` - this will cast the `value` (a model) to a `DBRef` value that is set in the `order` field\n\nIn addition if the `cache` option is set, then the object resolved from teh `DBRef` value will be \ncached in a cache property (`$order` for the `order` field) and the getter method signature\nwill be changed to `getOrder(callback, force)`.  The additional, optional, parameter `force`\ncan be used to bypass any cached value.\n\nThis plugin can be installed on the mongoose instance or on individual schema, but the \"owning\"\nmongoose instance for the schema must always be specified during the installation.\n\n#### Plugin: `dbrefHooks`\nThe `dbrefHooks` plugin can be used to create *hooks* that on the `model` and `schema` instances that\nmap to/from `DBRef` values.\n\nTo do this a `_dbref` virtual and a `fetch` static are installed on each `schema` created such that \nthe `_dbref` virtual will return the `DBRef` for the `model` instance, and the `fetch` static will\nresolve a supplied `DBRef` and invoke a callback function appropriately.\n\n### Using the patches\nOnce you have installed the patches, or installed the whole extension, you can begin to use them.\n\n#### Patch: `dbref.fetch`\nThis `fetch` monkey patch to the `DBRef` class can be used to resolve a `DBRef` value when supplied with \na mongoos database connection and a callback function.\n\n\tvar mongoose = require(\"mongoose\");\n\tvar db = mongoose.createConnection(\"mongodb://localhost/sampledb\");\n\t\n\tvar utils = require(\"mongoose-dbref\").utils;\n\t\n\tvar LineItem = db.model('LineItem');\n\t\n\tLineItem.findById(\"4dee1f473abd4fbc61000001\",\n\t\tfunction(err, doc) {\n\t\t\tdoc.order.fetch(db, \n\t\t\t\tfunction(err, doc) {\n\t\t\t\t    if (err) throw err;\n\t\t\t\t\tconsole.log(\"Order = \" + doc);\n\t\t\t\t});\n\t\t});\n\nIn this example, the `order` of a specific `LineItem` is fetched using the database connection that\nwas used to find the `LineItem` instance.\n\n### Using the utilities\nOnce you have installed the utilities, or installed the whole extension, you can begin to use them.\n\n#### Utility: `fetch`\nThis `fetch` utility function can be used to resolve a given `DBRef` value when supplied with a mongoose\ndatabase connection and a callback function.\n\n\tvar mongoose = require(\"mongoose\");\n\tvar db = mongoose.createConnection(\"mongodb://localhost/sampledb\");\n\t\n\tvar utils = require(\"mongoose-dbref\").utils;\n\t\n\tvar LineItem = db.model('LineItem');\n\t\n\tLineItem.findById(\"4dee1f473abd4fbc61000001\",\n\t\tfunction(err, doc) {\n\t\t\tutils.fetch(db, doc.order,\n\t\t\t\tfunction(err, doc) {\n\t\t\t\t    if (err) throw err;\n\t\t\t\t\tconsole.log(\"Order = \" + doc);\n\t\t\t\t});\n\t\t});\n\nIn this example, the `order` of a specific `LineItem` is fetched using the database connection that\nwas used to find the `LineItem` instance.\n\n### Contributors\n- [Stuart Hudson](https://github.com/goulash1971)\n\n### License\nMIT License\n\n### Acknowledgements\n- [Brian Noguchi](https://github.com/bnoguchi) for the 'mongoose-types' extension that was used as a template for this extension\n\n---\n### Author\nStuart Hudson\t\t \n","homepage":"https://github.com/goulash1971/mongoose-dbref","keywords":["mongodb","mongoose","mongo","types","dbref"],"contributors":[{"name":"Stuart Hudson","email":"goulash1971@yahoo.com","url":"http://goulash1971.com/"}],"bugs":{"url":"https://github.com/goulash1971/mongoose-dbref/issues"},"readmeFilename":"README.md"}