{"_id":"mongoose-relationship","_rev":"37-28720f5efeb8cdf112449f8da366f01e","name":"mongoose-relationship","description":"mongoose plugin to create maintain one-many and many-many bidirectional relationships between two schemas","dist-tags":{"latest":"0.1.5"},"versions":{"0.0.1":{"name":"mongoose-relationship","version":"0.0.1","description":"mongoose plugin to create maintain one-many and many-many bidirectional relationships between two schemas","main":"index.js","scripts":{"test":"mocha"},"keywords":["mongoose","parent"],"author":{"name":"Mike Sabatini","email":"mike@parallelboxes.com"},"license":"MIT","dependencies":{"underscore":"1.5.x"},"devDependencies":{"mocha":"1.14.x","should":"3.1.x","mongoose":"3.8.x","async":"0.2.x"},"repository":{"type":"git","url":"https://github.com/sabymike/mongoose-relationship"},"bugs":{"url":"https://github.com/sabymike/mongoose-relationship/issues"},"_id":"mongoose-relationship@0.0.1","dist":{"shasum":"f4ee2480a9e28146843d9e532f49de66f5747ca6","tarball":"https://registry.npmjs.org/mongoose-relationship/-/mongoose-relationship-0.0.1.tgz","integrity":"sha512-UNd9EHbHUyR95AB19SNYm6NgOmCUnTs4Ugn1Yd013E1r/Aq9vwn7ojIli8GSwVsBUynWYgTcHKikeGYLxvxdQw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCpojNuNCmw/NI590+UuYdlX+8O9vjS6iyX1E0biETO9wIgMj6jNTEGLEGCufwKZ5yqrBzcmgsonLJtB37a5jzVs6A="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"sabymike","email":"msabatini@gmail.com"},"maintainers":[{"name":"sabymike","email":"msabatini@gmail.com"}]},"0.0.2":{"name":"mongoose-relationship","version":"0.0.2","description":"mongoose plugin to create maintain one-many and many-many bidirectional relationships between two schemas","main":"index.js","scripts":{"test":"mocha"},"keywords":["mongoose","parent"],"author":{"name":"Mike Sabatini","email":"mike@parallelboxes.com"},"license":"MIT","dependencies":{"underscore":"1.5.x","async":"0.2.x"},"devDependencies":{"mocha":"1.14.x","should":"3.1.x","mongoose":"3.8.x"},"repository":{"type":"git","url":"https://github.com/sabymike/mongoose-relationship"},"bugs":{"url":"https://github.com/sabymike/mongoose-relationship/issues"},"_id":"mongoose-relationship@0.0.2","dist":{"shasum":"dd07d6845b00d2ee79702173ab616f5332ccb19b","tarball":"https://registry.npmjs.org/mongoose-relationship/-/mongoose-relationship-0.0.2.tgz","integrity":"sha512-EKVD3mIq/6L2xFaAMLL5xCxIENTW1bbYT8k8kPl/epuYBpT69K6ltl3SayVGEGuwHj3y5P6/1Wi5htQI1w3x3g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFocI+dXs+aYV52RRV8a8zcRyIcHJHVAbTHXFSb6ysxJAiEAtMWNtkSVR9RAkBpvvuQe6VcjoH3jLsUq6n6tua3rx7k="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"sabymike","email":"msabatini@gmail.com"},"maintainers":[{"name":"sabymike","email":"msabatini@gmail.com"}]},"0.0.3":{"name":"mongoose-relationship","version":"0.0.3","description":"mongoose plugin to create maintain one-many and many-many bidirectional relationships between two schemas","main":"index.js","scripts":{"test":"mocha"},"keywords":["mongoose","parent"],"author":{"name":"Mike Sabatini","email":"mike@parallelboxes.com"},"license":"MIT","dependencies":{"underscore":"1.5.x","async":"0.2.x"},"devDependencies":{"mocha":"1.14.x","should":"3.1.x","mongoose":"3.8.x"},"repository":{"type":"git","url":"https://github.com/sabymike/mongoose-relationship"},"bugs":{"url":"https://github.com/sabymike/mongoose-relationship/issues"},"_id":"mongoose-relationship@0.0.3","dist":{"shasum":"dfc1368591bce69c67d8f3f8861708e7e4c699bb","tarball":"https://registry.npmjs.org/mongoose-relationship/-/mongoose-relationship-0.0.3.tgz","integrity":"sha512-1864YwDFNED/3lD0wWnq9CvGb/iIMxxcIbRZZaTDIiLQNHfKb9R0i7KuxjpWi+a2HvWyUq8DIYMM7Mgzf1l6Ug==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDx6y5xA9kGWVJ4r/IS90thrxb2vy0y2+q5riyjli2tXAIhAP89Nd9k3VmQFL/uoF/b+OevF5pvi6JVgxPSNbymvlRK"}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"sabymike","email":"msabatini@gmail.com"},"maintainers":[{"name":"sabymike","email":"msabatini@gmail.com"}]},"0.0.4":{"name":"mongoose-relationship","version":"0.0.4","description":"mongoose plugin to create maintain one-many and many-many bidirectional relationships between two schemas","main":"index.js","scripts":{"test":"mocha"},"keywords":["mongoose","parent"],"author":{"name":"Mike Sabatini","email":"mike@parallelboxes.com"},"license":"MIT","dependencies":{"underscore":"1.5.x","async":"0.2.x"},"devDependencies":{"mocha":"1.14.x","should":"3.1.x","mongoose":"3.8.x"},"repository":{"type":"git","url":"https://github.com/sabymike/mongoose-relationship"},"bugs":{"url":"https://github.com/sabymike/mongoose-relationship/issues"},"homepage":"https://github.com/sabymike/mongoose-relationship","_id":"mongoose-relationship@0.0.4","dist":{"shasum":"7913bbf540f202b7ceec6803818fa3169e95b3d2","tarball":"https://registry.npmjs.org/mongoose-relationship/-/mongoose-relationship-0.0.4.tgz","integrity":"sha512-2hEFdf0Z2hf31uAOoS5mvi4RKRsJiX8u5qh4z7Cr/3wwNQpEruoH5OlyhngUE3KUsFPBnYKm7LcH7j0C8cezfg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDqu5afJZ8s/hB+pFNZB2PZXhLQk7J4yBcUl1CY6gZs4QIgb+taNvduQEWpZ++hgbqXmErrqgWp45aSv4kQ/oxHCEg="}]},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"sabymike","email":"msabatini@gmail.com"},"maintainers":[{"name":"sabymike","email":"msabatini@gmail.com"}]},"0.0.5":{"name":"mongoose-relationship","version":"0.0.5","description":"mongoose plugin to create maintain one-many and many-many bidirectional relationships between two schemas","main":"index.js","scripts":{"test":"mocha"},"keywords":["mongoose","parent"],"author":{"name":"Mike Sabatini","email":"mike@parallelboxes.com"},"license":"MIT","dependencies":{"underscore":"1.5.x","async":"0.2.x"},"devDependencies":{"mocha":"1.14.x","should":"3.1.x","mongoose":"3.8.x"},"repository":{"type":"git","url":"https://github.com/sabymike/mongoose-relationship"},"bugs":{"url":"https://github.com/sabymike/mongoose-relationship/issues"},"homepage":"https://github.com/sabymike/mongoose-relationship","_id":"mongoose-relationship@0.0.5","dist":{"shasum":"63308519061552b3e4e46f4ae7676d3661437203","tarball":"https://registry.npmjs.org/mongoose-relationship/-/mongoose-relationship-0.0.5.tgz","integrity":"sha512-pgaT398iwewpiHcbR9iFp9Hp1KpSaQVvcLEjNyVjuj+sXVkhA05dns+M2LtE0flpBwrHRNl4PYliMiezjI1CEw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE4hWWjuVLJ1TFyl/xkkglluhon6JFvFCBhHsqM2OIbyAiBhvyqUTOUTgFD3cOM5iyjTlYV66vRSnC+mKXvl9ttizA=="}]},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"sabymike","email":"msabatini@gmail.com"},"maintainers":[{"name":"sabymike","email":"msabatini@gmail.com"}]},"0.0.6":{"name":"mongoose-relationship","version":"0.0.6","description":"mongoose plugin to create maintain one-many and many-many bidirectional relationships between two schemas","main":"index.js","scripts":{"test":"mocha"},"keywords":["mongoose","parent"],"author":{"name":"Mike Sabatini","email":"mike@parallelboxes.com"},"license":"MIT","dependencies":{"underscore":"1.5.x","async":"0.2.x"},"devDependencies":{"mocha":"1.14.x","should":"3.1.x","mongoose":"3.8.x"},"repository":{"type":"git","url":"https://github.com/sabymike/mongoose-relationship"},"bugs":{"url":"https://github.com/sabymike/mongoose-relationship/issues"},"homepage":"https://github.com/sabymike/mongoose-relationship","_id":"mongoose-relationship@0.0.6","dist":{"shasum":"2001d086c736f8726f87c478394f898b6ce8133c","tarball":"https://registry.npmjs.org/mongoose-relationship/-/mongoose-relationship-0.0.6.tgz","integrity":"sha512-JXlCidApt1uEEP3cX8vrHIpXgRNqHm2chNrQw7PjtnoAERxSG5EhBkPouEhYvEY9EPSKy1hfNJjj7uAKC7GlFQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGRt16lcYTwHfSOGw7pc9UwDhk7Qu7zWS2Oz4L0FJwEtAiEAkt4HVEdNSPPf1AIPPiWJNogS3Lh41bI0Nq68taLZAxs="}]},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"sabymike","email":"msabatini@gmail.com"},"maintainers":[{"name":"sabymike","email":"msabatini@gmail.com"}]},"0.0.7":{"name":"mongoose-relationship","version":"0.0.7","description":"mongoose plugin to create maintain one-many and many-many bidirectional relationships between two schemas","main":"index.js","scripts":{"test":"make test"},"keywords":["mongoose","parent"],"author":{"name":"Mike Sabatini","email":"mike@parallelboxes.com"},"license":"MIT","dependencies":{"underscore":"1.5.x","async":"0.2.x"},"devDependencies":{"mocha":"1.14.x","should":"3.1.x","mongoose":"3.8.x"},"repository":{"type":"git","url":"https://github.com/sabymike/mongoose-relationship"},"bugs":{"url":"https://github.com/sabymike/mongoose-relationship/issues"},"homepage":"https://github.com/sabymike/mongoose-relationship","_id":"mongoose-relationship@0.0.7","dist":{"shasum":"c4038235d4aeee9b4e9b5097d9cf01b516863130","tarball":"https://registry.npmjs.org/mongoose-relationship/-/mongoose-relationship-0.0.7.tgz","integrity":"sha512-JbY2BtD4sU4jazc2UJoSqlkqQ8K3EFO7BRh5SbQqfQL0dKAeeCE4QRx0UNiday673hGRzNDLKDv05WhU5boYjw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAZ6L6qAR/o5KHELrFur8h9NNBy8110Nlq8RcfcfhCoGAiEAz5hLWL9eaHXz16KMRbp0u2LnYEd/aO9zb7MgpkoqauA="}]},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"sabymike","email":"msabatini@gmail.com"},"maintainers":[{"name":"sabymike","email":"msabatini@gmail.com"}]},"0.0.8":{"name":"mongoose-relationship","version":"0.0.8","description":"mongoose plugin to create maintain one-many and many-many bidirectional relationships between two schemas","main":"index.js","scripts":{"test":"make test"},"keywords":["mongoose","parent"],"author":{"name":"Mike Sabatini","email":"mike@parallelboxes.com"},"license":"MIT","dependencies":{"underscore":"1.5.x","async":"0.2.x"},"devDependencies":{"mocha":"1.14.x","should":"3.1.x","mongoose":"3.8.x"},"repository":{"type":"git","url":"https://github.com/sabymike/mongoose-relationship"},"bugs":{"url":"https://github.com/sabymike/mongoose-relationship/issues"},"homepage":"https://github.com/sabymike/mongoose-relationship","_id":"mongoose-relationship@0.0.8","dist":{"shasum":"38951e1e9ad045427683c87da4cd6f013034df2e","tarball":"https://registry.npmjs.org/mongoose-relationship/-/mongoose-relationship-0.0.8.tgz","integrity":"sha512-dwgPnR3nDrgsXpNhzBj1cUwHt92JDrUojYRA27PsvBV+uhP9XTZnf8EoqsyFlCzDOMDegEnZ0PjWm9LTwTV8LQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCRmxOXmsdomgoAcTODR6y7DTVWtPNARMCSw5feoW4c2QIhAKL0hcJEZdrzl+VxjEMkkP1pz2icPUGnr88I4kT5TvBC"}]},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"sabymike","email":"msabatini@gmail.com"},"maintainers":[{"name":"sabymike","email":"msabatini@gmail.com"}]},"0.1.0":{"name":"mongoose-relationship","version":"0.1.0","description":"mongoose plugin to create maintain one-many and many-many bidirectional relationships between two schemas","main":"index.js","scripts":{"test":"make test"},"keywords":["mongoose","parent"],"author":{"name":"Mike Sabatini","email":"mike@parallelboxes.com"},"license":"MIT","dependencies":{"underscore":"1.5.x","async":"0.2.x"},"devDependencies":{"mocha":"1.14.x","should":"3.1.x","mongoose":"3.8.x"},"repository":{"type":"git","url":"https://github.com/sabymike/mongoose-relationship"},"bugs":{"url":"https://github.com/sabymike/mongoose-relationship/issues"},"homepage":"https://github.com/sabymike/mongoose-relationship","_id":"mongoose-relationship@0.1.0","dist":{"shasum":"25f8368b7f7c9670408a1b1c442429814727f8d1","tarball":"https://registry.npmjs.org/mongoose-relationship/-/mongoose-relationship-0.1.0.tgz","integrity":"sha512-LNwehcPKgnu2zJnbaEQR6eoUpRmjELS58MHv4LGlm/PElKrKyGr/6uyKGcErOjeDiFQUhTNRnEQK4n9hZPmOYg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEKUacyTWnBX97AhDAJnvc2oYEdQC6XPeWxw9i7RZYUpAiAZY9JIEbP0zbvtqjJYaduxvznl07vbTtrp+Y/4TP4nqg=="}]},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"sabymike","email":"msabatini@gmail.com"},"maintainers":[{"name":"sabymike","email":"msabatini@gmail.com"}]},"0.1.1":{"name":"mongoose-relationship","version":"0.1.1","description":"mongoose plugin to create maintain one-many and many-many bidirectional relationships between two schemas","main":"index.js","scripts":{"test":"make test"},"keywords":["mongoose","parent"],"author":{"name":"Mike Sabatini","email":"mike@parallelboxes.com"},"license":"MIT","dependencies":{"underscore":"1.5.x","async":"0.2.x"},"devDependencies":{"mocha":"1.14.x","should":"3.1.x","mongoose":"3.8.x"},"repository":{"type":"git","url":"https://github.com/sabymike/mongoose-relationship"},"bugs":{"url":"https://github.com/sabymike/mongoose-relationship/issues"},"homepage":"https://github.com/sabymike/mongoose-relationship","_id":"mongoose-relationship@0.1.1","dist":{"shasum":"a4a45fabc6b7ce9f09193901d8cd8533a132e465","tarball":"https://registry.npmjs.org/mongoose-relationship/-/mongoose-relationship-0.1.1.tgz","integrity":"sha512-ir9dTGowO5uxDUr+ICanc6CxjjlXdWWmYVtTOVmjrNnyFGID3Ewjm4etBXDNSOi7Nn5QarjgBeVwjguuTH0f7g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDbCHoBkXdK5fBD+kcvB2IV1vBcTGWaGEszAdNViGRk4AiEAv9qdTxUqH/KCHkf8nSVrvkj8KLBSh7aIKqErP0hluJE="}]},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"sabymike","email":"msabatini@gmail.com"},"maintainers":[{"name":"sabymike","email":"msabatini@gmail.com"}]},"0.1.2":{"name":"mongoose-relationship","version":"0.1.2","description":"mongoose plugin to create maintain one-many and many-many bidirectional relationships between two schemas","main":"index.js","scripts":{"test":"make test"},"keywords":["mongoose","parent"],"author":{"name":"Mike Sabatini","email":"mike@parallelboxes.com"},"license":"MIT","dependencies":{"underscore":"1.5.x","async":"0.2.x"},"devDependencies":{"mocha":"1.14.x","should":"3.1.x","mongoose":"3.8.x"},"repository":{"type":"git","url":"https://github.com/sabymike/mongoose-relationship"},"bugs":{"url":"https://github.com/sabymike/mongoose-relationship/issues"},"homepage":"https://github.com/sabymike/mongoose-relationship","_id":"mongoose-relationship@0.1.2","dist":{"shasum":"2107d885dcc6baacbffec193f7d3519bd80c7e17","tarball":"https://registry.npmjs.org/mongoose-relationship/-/mongoose-relationship-0.1.2.tgz","integrity":"sha512-nG6qqPRKR1vL9Qmjehky2uso44YsfqkfROO1CeFgK8ydXWsC5hzOipYjv3UjU47nweKpZtWRm0W04w0fldi2xg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFAPNzl7n5OP5QW4Gkd2nJb4Vxm9OMj65HqH9RbVhRIdAiEA+25ExYnDr9RV2HW3fpcvRvtaaOzNz0lvKzk/Eu7+A3U="}]},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"sabymike","email":"msabatini@gmail.com"},"maintainers":[{"name":"sabymike","email":"msabatini@gmail.com"}]},"0.1.4":{"name":"mongoose-relationship","description":"mongoose plugin to create maintain one-many and many-many bidirectional relationships between two schemas","version":"0.1.4","author":{"name":"Mike Sabatini","email":"mike@parallelboxes.com"},"dependencies":{"async":"0.2.10","lodash":"^3.3.1"},"devDependencies":{"mocha":"^2.1.0","mongoose":"~3.8.24","should":"^5.1.0"},"keywords":["mongoose","parent"],"license":"MIT","main":"index.js","repository":{"type":"git","url":"https://github.com/sabymike/mongoose-relationship"},"scripts":{"test":"mocha test -R spec"},"bugs":{"url":"https://github.com/sabymike/mongoose-relationship/issues"},"homepage":"https://github.com/sabymike/mongoose-relationship","_id":"mongoose-relationship@0.1.4","dist":{"shasum":"fd8a20f12cf2da692ffe4b33d7bd8f509cac785c","tarball":"https://registry.npmjs.org/mongoose-relationship/-/mongoose-relationship-0.1.4.tgz","integrity":"sha512-TQI63HgW8g0OgY8NhJ74PzoJeSUafoGKvZpfZQM7lLrTNaMaZuYOMJe0vBT3Z6LP8HN1dMo/GlskgSGzgab1Ag==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICGHXOP3JyzdZPxPMyowIG4hFqaIgwTr8sNDhQU/Atl8AiEAoWyQ5qoDv+6tlqnZiC4Lj24VCMYkFUIDGIcjZc4T+LU="}]},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"sabymike","email":"msabatini@gmail.com"},"maintainers":[{"name":"sabymike","email":"msabatini@gmail.com"}]},"0.1.5":{"name":"mongoose-relationship","description":"mongoose plugin to create maintain one-many and many-many bidirectional relationships between two schemas","version":"0.1.5","author":{"name":"Mike Sabatini","email":"mike@parallelboxes.com"},"dependencies":{"async":"0.2.10","lodash":"^3.3.1"},"devDependencies":{"mocha":"^2.1.0","mongoose":"~3.8.24","should":"^5.1.0"},"keywords":["mongoose","parent"],"license":"MIT","main":"index.js","repository":{"type":"git","url":"git+https://github.com/sabymike/mongoose-relationship.git"},"scripts":{"test":"mocha test -R spec"},"gitHead":"0c21a5a3b074a4e57680864a01756f6c0cd4da91","bugs":{"url":"https://github.com/sabymike/mongoose-relationship/issues"},"homepage":"https://github.com/sabymike/mongoose-relationship#readme","_id":"mongoose-relationship@0.1.5","_shasum":"2a95fdeae41f295a81d9b327fad1cf64af13c27a","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.2","_npmUser":{"name":"sabymike","email":"msabatini@gmail.com"},"dist":{"shasum":"2a95fdeae41f295a81d9b327fad1cf64af13c27a","tarball":"https://registry.npmjs.org/mongoose-relationship/-/mongoose-relationship-0.1.5.tgz","integrity":"sha512-/X0VQwga47Af8WS0VhiBjzsIP9ekvypIgyT3mvbX9eelvV3wLxl6RljO1Bk4a8RVi2H8v8eatcV+gRnPGKrMEg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFfwiVJXfjX19OywtBVzdjwX2KVqqxbQNfDSIV+EFm48AiBgTbB6m4X68o/uS4lLWqScor+V5xKheoLVyc1OX7uJYQ=="}]},"maintainers":[{"name":"sabymike","email":"msabatini@gmail.com"}]}},"readme":"## mongoose-relationship\n\n_**Note**: Maintenence on this module is deprecated. I had personally been using it for a project and over time have realized that bi-directional relationships in mongoose can become extremely complex and hinder performance as a project grows. The more I learn about mongo and designing data for it, the less likely these relationships make sense._\n\nA mongoose plugin that creates and manages relationships between two separate models. These relationships can be One-To-One, One-To-Many, or Many-To-Many. These changes are currently one-direction. If you manipulate a parents \"child\" property or collection, the child values will not be updated. Only changes made to the child model will update its parent.\n\n#Install\nInstall via NPM\n\n        npm install mongoose-relationship\n\n# Usage\n\n##One-To-Many\n```js\nvar mongoose = require(\"mongoose\"),\n    Schema = mongoose.Schema,\n    relationship = require(\"mongoose-relationship\");\n\nvar ParentSchema = new Schema({\n    children:[{ type:Schema.ObjectId, ref:\"Child\" }]\n});\nvar Parent = mongoose.model(\"Parent\", ParentSchema);\n\nvar ChildSchema = new Schema({\n    parent: { type:Schema.ObjectId, ref:\"Parent\", childPath:\"children\" }\n});\nChildSchema.plugin(relationship, { relationshipPathName:'parent' });\nvar Child = mongoose.model(\"Child\", ChildSchema)\n\nvar parent = new Parent({});\nparent.save();\nvar child = new Child({parent:parent._id});\nchild.save() //the parent children property will now contain child's id\nchild.remove() //the parent children property will no longer contain the child's id\n```\n\n##Many-To-Many\n```js\nvar mongoose = require(\"mongoose\"),\n    Schema = mongoose.Schema,\n    relationship = require(\"mongoose-relationship\");\n\nvar ParentSchema = new Schema({\n    children:[{ type:Schema.ObjectId, ref:\"Child\" }]\n});\nvar Parent = mongoose.model(\"Parent\", ParentSchema);\n\nvar ChildSchema = new Schema({\n    parents: [{ type:Schema.ObjectId, ref:\"Parent\", childPath:\"children\" }]\n});\nChildSchema.plugin(relationship, { relationshipPathName:'parents' });\nvar Child = mongoose.model(\"Child\", ChildSchema)\n\nvar parent = new Parent({});\nparent.save();\nvar parentTwo = new Parent({});\nparentTwo.save();\n\nvar child = new Child({});\nchild.parents.push(parent);\nchild.parents.push(parentTwo);\nchild.save() //both parent and parentTwo children property will now contain the child's id\nchild.remove() //both parent and parentTwo children property will no longer contain the child's id\n```\n\n##Many-To-Many with Multiple paths\n```js\nvar mongoose = require(\"mongoose\"),\n    Schema = mongoose.Schema,\n    relationship = require(\"mongoose-relationship\");\n\nvar ParentSchema = new Schema({\n    children:[{ type:Schema.ObjectId, ref:\"Child\" }]\n});\nvar Parent = mongoose.model(\"Parent\", ParentSchema);\n\nvar OtherParentSchema = new Schema({\n    children:[{ type:Schema.ObjectId, ref:\"Child\" }]\n});\nvar OtherParent = mongoose.model(\"OtherParent\", OtherParentSchema);\n\nvar ChildSchema = new Schema({\n    parents: [{ type:Schema.ObjectId, ref:\"Parent\", childPath:\"children\" }]\n    otherParents: [{ type:Schema.ObjectId, ref:\"OtherParent\", childPath:\"children\" }]\n});\nChildSchema.plugin(relationship, { relationshipPathName:['parents', 'otherParents'] });\nvar Child = mongoose.model(\"Child\", ChildSchema)\n\nvar parent = new Parent({});\nparent.save();\nvar otherParent = new OtherParent({});\notherParent.save();\n\nvar child = new Child({});\nchild.parents.push(parent);\nchild.otherParents.push(otherParent);\nchild.save() //both parent and otherParent children property will now contain the child's id\nchild.remove() //both parent and otherParent children property will no longer contain the child's id\n```\n\n##One-To-One\n**This usage scenario will overwrite the parent's field of multiple children are assigned the same parent. The use case for this operation seems to be limited and only included for a sense of completion.**\n\n```js\nvar mongoose = require(\"mongoose\"),\n    Schema = mongoose.Schema,\n    relationship = require(\"mongoose-relationship\");\n\nvar ParentSchema = new Schema({\n    child:{ type:Schema.ObjectId, ref:\"Child\" }\n});\nvar Parent = mongoose.model(\"Parent\", ParentSchema);\n\nvar ChildSchema = new Schema({\n    parent: { type:Schema.ObjectId, ref:\"Parent\", childPath:\"child\" }\n});\nChildSchema.plugin(relationship, { relationshipPathName:'parent' });\nvar Child = mongoose.model(\"Child\", ChildSchema)\n\nvar parent = new Parent({});\nparent.save();\nvar child = new Child({parent:parent._id});\nchild.save() // The parent's child property will now be set to the child's _id;\nchild.remove() // The parent's child property will now be unset\n```\n\n###Options\n\n####Plugin\nThe plugin currently has the following options\n\n- **relationshipPathName**\n\n    A string or array to let the plugin know which path(s) on your schema the relationship will be created. Defaults to **relationship**\n\n- **triggerMiddleware**\n\n    Boolean value which, if set to true, will explicitly save any parents entities when a relationship is updated causing save middleware to execute. Defaults to **false**\n\n####Path Value\nWhen creating a path on a schema that will represent the relationship, the childPath option is required\n\n- **childPath**\n\n    A string which should match an existing path in target ref schema. If this path does not exist the plugin will have no affect on the target ref.\n\n- **validateExistence**\n\n    Boolean value that tells mongoose-relationship to ensure that the parent exists before setting the relationship for the child. Defaults to **false**\n\n- **upsert**\n\n    Boolean value that controls whether a parent should be created if it does not exist upon child save. Defaults to **false**\n\n# Tests\nTest can be run simply by installing and running mocha\n\n    npm install -g mocha\n    mocha\n\n#Authors\nMike Sabatini [@mikesabatini](https://twitter.com/mikesabatini)\n\n#License\nCopyright Mike Sabatini 2014\nLicensed under the MIT License. Enjoy\n","maintainers":[{"name":"sabymike","email":"msabatini@gmail.com"}],"time":{"modified":"2022-06-20T07:41:19.275Z","created":"2014-02-13T19:07:24.287Z","0.0.1":"2014-02-13T19:07:50.642Z","0.0.2":"2014-02-14T16:11:58.800Z","0.0.3":"2014-02-19T16:46:15.914Z","0.0.4":"2014-02-28T19:28:07.977Z","0.0.5":"2014-04-24T15:53:11.233Z","0.0.6":"2014-06-02T15:11:30.842Z","0.0.7":"2014-12-08T22:28:10.465Z","0.0.8":"2014-12-10T16:12:03.954Z","0.1.0":"2015-02-06T21:52:34.244Z","0.1.1":"2015-02-09T17:07:28.353Z","0.1.2":"2015-03-05T01:48:45.095Z","0.1.4":"2015-03-12T18:46:53.276Z","0.1.5":"2016-01-08T16:23:25.678Z"},"readmeFilename":"README.md","author":{"name":"Mike Sabatini","email":"mike@parallelboxes.com"},"repository":{"type":"git","url":"git+https://github.com/sabymike/mongoose-relationship.git"},"keywords":["mongoose","parent"],"bugs":{"url":"https://github.com/sabymike/mongoose-relationship/issues"},"license":"MIT","homepage":"https://github.com/sabymike/mongoose-relationship#readme","users":{"saravananr":true,"scoch":true,"martinspinks":true,"bengi":true}}