{"_id":"modef","_rev":"20-89a88c3e8c6b193649ee677c02a02fe0","name":"modef","description":"Helper for defining connected models in mongoose","dist-tags":{"latest":"0.1.3"},"versions":{"0.1.0":{"author":{"name":"Rouzbeh Delavari","email":"rouzwawi@gmail.com"},"name":"modef","description":"Helper for defining connected models in mongoose","version":"0.1.0","repository":{"type":"git","url":"git://github.com/rouzwawi/modef.git"},"main":"index","engines":{"node":"~0.6.0"},"dependencies":{},"devDependencies":{"mongoose":">= 2.3.12"},"_npmUser":{"name":"rouzwawi","email":"rouzwawi@gmail.com"},"_id":"modef@0.1.0","_engineSupported":true,"_npmVersion":"1.0.105","_nodeVersion":"v0.6.1","_defaultsLoaded":true,"dist":{"shasum":"779f4bfb4bdae93ce55e1e55ddbc4be5cccdf02a","tarball":"https://registry.npmjs.org/modef/-/modef-0.1.0.tgz","integrity":"sha512-IHebOAa1IOnQqnL1GnYptHeuR5945tQIuoWbHo7DF8ChOPgoQ4CWZJUsR2EM2cW1bnbUlJvJy1qPqF0F3w1O8Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCbZIY6qU45r4BT+YCeuJwP+s3oqPlKQMFjrCXoSxHjUAIhAMNYsklAIj1uyfQ+0HfHGpTX1ahUzllnenBvaBm1ZwIR"}]},"maintainers":[{"name":"rouzwawi","email":"rouzwawi@gmail.com"}],"directories":{}},"0.1.1":{"author":{"name":"Rouzbeh Delavari","email":"rouzwawi@gmail.com"},"name":"modef","description":"Helper for defining connected models in mongoose","version":"0.1.1","repository":{"type":"git","url":"git://github.com/rouzwawi/modef.git"},"main":"index","engines":{"node":"~0.6.0"},"devDependencies":{"mongoose":">= 2.5.7"},"dependencies":{"tamejs":">= 0.4.5"},"_npmUser":{"name":"rouzwawi","email":"rouzwawi@gmail.com"},"_id":"modef@0.1.1","optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.15","_nodeVersion":"v0.6.10","_defaultsLoaded":true,"dist":{"shasum":"a940b6b4d9a0c97686cd0992f839a80988736117","tarball":"https://registry.npmjs.org/modef/-/modef-0.1.1.tgz","integrity":"sha512-eJhpR5EpxSrqBAbzoozQmOsEv/BrR0Yfj8eTNz58Ay6nwwm/9JjUUTU2Z+v6S9aD6zv4l2OhYnzsKMPiT97l1Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCTAdQiNmJKlKvOsBIcr7WEDldaLRJ7eq4gk1i2J+5QeAIhAJizIeT2MKxMTOvjHVztGivHjb0woYXPJoRYRctDclSY"}]},"maintainers":[{"name":"rouzwawi","email":"rouzwawi@gmail.com"}],"directories":{}},"0.1.2":{"author":{"name":"Rouzbeh Delavari","email":"rouzwawi@gmail.com"},"name":"modef","description":"Helper for defining connected models in mongoose","version":"0.1.2","repository":{"type":"git","url":"git://github.com/rouzwawi/modef.git"},"main":"index","engines":{"node":"~0.6.0"},"devDependencies":{"mongoose":">= 2.5.7"},"dependencies":{"tamejs":">= 0.4.5"},"_npmUser":{"name":"rouzwawi","email":"rouzwawi@gmail.com"},"_id":"modef@0.1.2","optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.15","_nodeVersion":"v0.6.10","_defaultsLoaded":true,"dist":{"shasum":"252b5159d6687acafa6d202631986044b9e2cbf8","tarball":"https://registry.npmjs.org/modef/-/modef-0.1.2.tgz","integrity":"sha512-qEXkLMBcT4Cd5xNIbSVYLiHOHoNGePLaHjePz4e7K0Cbz8PqA7EJ6hTHkX+13HfiE8w7q6/3C9N+5w/CIc5BNw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAqqyMZjT5VPeGNvvi7b1kLPyS3tx9kkQJMLfUkhPJYrAiAgq5AsmsmyFiwszwwcbI9N4pbVgDb8QwvkzkwhypgQ+A=="}]},"maintainers":[{"name":"rouzwawi","email":"rouzwawi@gmail.com"}],"directories":{}},"0.1.3":{"author":{"name":"Rouzbeh Delavari","email":"rouzwawi@gmail.com"},"name":"modef","description":"Helper for defining connected models in mongoose","version":"0.1.3","repository":{"type":"git","url":"git://github.com/rouzwawi/modef.git"},"main":"index","engines":{"node":"~0.6.0"},"devDependencies":{"mongoose":">= 2.5.7"},"dependencies":{"tamejs":"0.4.5"},"readme":"# modef\n\n\n## Installation\n\tnpm install modef\n\n\n## Connect Mongoose\n\tvar mongoose = require('mongoose');\n\tvar mongooseDb = mongoose.connect('mongodb://localhost/blog');\n\n\n## Require Modef\n\tvar modef = require('modef');\n\tvar model\t= modef.model,\n\t\tcommon\t= modef.common,\n\t\tcreate\t= modef.create\n\t;\n\n\n## Example Usage\n\tvar Author = {\n\t\tusername: { type: String }\n\t};\n\n\t// Common schema for several entities\n\tvar PostAndComment = {\n\t\tbody: { type: String },\n\t\tdate: { type: Date, default: function(){ return new Date(); } }\n\t};\n\n\tvar Picture = {\n\t\turl: { type: String }\n\t};\n\n\t// one-to-many connections imply opposite many-to-one connection\n\t// Picture-Post has many-to-many connection\n\t// model('<entity-name>', <connections>*, MongooseSchema)\n\tmodel('Author' ,  Author);\n\tmodel('Post'   , 'Author', ['Picture'], PostAndComment);\n\tmodel('Comment', 'Post'  ,  'Author'  , PostAndComment);\n\tmodel('Picture', 'Author', ['Post']   , Picture);\n\n\t// Fields common to all models\n\tcommon('name', { type: String, index: true });\n\n\tcreate();\n\n\n## View your models\n\tmodef.printHierarchies();\n\n\n\tAuthor (root)\n\t `- Post\n\t |   `- Picture -> Post\n\t |   `- Comment\n\t `- Comment\n\t `- Picture\n\t     `- Post -> Picture\n\t         `- Comment\n\n\n## Use defined Mongoose Models\n\t// modef exports mongoose models\n\tvar post = new modef['Post']();\n\tpost.body = 'Lorem ipsum dolor sit amet, consectetur...';\n\tpost.save();\n\n\tvar author = new modef['Author']();\n\tauthor.name = 'John Author';\n\tauthor.username = 'john.author';\n\tauthor.posts.push(post);\n\tauthor.save();\n\n\n# destrruc\n\n\n## prerequisites\n[modef](https://github.com/rouzwawi/modef)\n\n\n## Installation\n\tnpm install destrruc\n\n\n## Use\nDefine your models using modef. Here done in a separate module (see modef docs).\n\n\trequire('./model/blog-models.js');\n\nUse `destrruc()` function in express server to set up resource routes.\n\n\tvar express = require('express');\n\tvar app = express.createServer();\n\n\tapp.destrruc();\n\nThis will set up CRUD routes for all your modef defined models.\n\n\tPOST    /:model      ->  Create Model from req.body\n\tGET     /:model/:id  ->  Return Model :id as JSON\n\tPUT     /:model/:id  ->  Update Model :id to req.body (per field updates)\n\tDELETE  /:model/:id  ->  Delete Model :id\n\n\n## Setup options\nSetting up destrruc, you can pass these options to customize some of the behavior.\nThese are the defaults.\n\n\tapp.destrruc({\n\t\trender: function(req, res, modelName, entity, next) {\n\t\t\tres.JSON(entity);\n\t\t},\n\t\tid: function(id) { return { _id: id }; }\n\t});\n\n`render:` - A callback function for rendering the entity\n\n`id:` - A function for creating a mongoose query object from the :id parameter\n\n\n## Populating connections\nUsing [mongoose populate](http://mongoosejs.com/docs/populate.html) destrruc gives\nyou a way to populate connected fields when doing GETs. Note, this only goes down one\nlevel in the connections.\n\nIf we have a one-to-many connection between Authors and Posts, Authors will have a list\nof references to Posts, and Posts will have a field with a reference to an Author.\nThese fields can be populated using the 'include' query parameter.\n\n\t/author/:id?include=posts\n\t/post/:id?include=author\n\nThe general syntax for the include query parameter is:\n\n\tinclude-caluse = <connection>[.<field>[|<field> ...]]\n\t?include=<include-clause>[,<include-clause> ...]\n\nSome examples:\n\n\t# author with posts\n\t/author/:id?include=posts\n\t\n\t# author with posts, but only post heading and date\n\t/author/:id?include=posts.heading|date\n\t\n\t# same as above, but also include the authors pictures names\n\t/author/:id?include=posts.heading|date,pictures.name\n\n\n## Events\n\n\tdestrruc.audit(function(action, modelName, entity, fields) {\n\t\tconsole.log('action:%s, model:%s, id:%s', action, modelName, entity._id);\n\t\tfor (field in fields) {\n\t\t\tconsole.log('\\t %s = %s', field, fields[field]);\n\t\t}\n\t});\n","_id":"modef@0.1.3","dist":{"shasum":"9d5543f31d400cc0467c1562c37a12926e7df80a","tarball":"https://registry.npmjs.org/modef/-/modef-0.1.3.tgz","integrity":"sha512-XYb++V1bZSSI+ahFkJTZ0+2QvnXpOUrRJz402FncfBI7fWw1S/kfMDjnxjCsU3bgoabiJdqDZ/2JNZ4DslbRNg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC1vam0MCvC06jHqIt+hPOz617vcPXtGrQVfTssXUnGjgIgK6QBKCGIHPWw5vQF71su7F9c5M7vZ+eaHLGKfCG/5ME="}]},"maintainers":[{"name":"rouzwawi","email":"rouzwawi@gmail.com"}]}},"readme":"# modef\n\n## Connect Mongoose\n\tvar mongoose = require('mongoose');\n\tvar mongooseDb = mongoose.connect('mongodb://localhost/blog');\n\n\n## Require Modef\n\tvar modef = require('modef');\n\tvar model\t= modef.model,\n\t\tcommon\t= modef.common,\n\t\tcreate\t= modef.create\n\t;\n\n\n## Example Usage\n\tvar Author = {\n\t\tusername: { type: String }\n\t};\n\n\t// Common schema for several entities\n\tvar PostAndComment = {\n\t\tbody: { type: String },\n\t\tdate: { type: Date, default: function(){ return new Date(); } }\n\t};\n\n\tvar Picture = {\n\t\turl: { type: String }\n\t};\n\n\t// one-to-many connections imply opposite many-to-one connection\n\t// Picture-Post has many-to-many connection\n\t// model('<entity-name>', <connections>*, MongooseSchema)\n\tmodel('Author' ,  Author);\n\tmodel('Post'   , 'Author', ['Picture'], PostAndComment);\n\tmodel('Comment', 'Post'  ,  'Author'  , PostAndComment);\n\tmodel('Picture', 'Author', ['Post']   , Picture);\n\n\t// Fields common to all models\n\tcommon('name', { type: String, index: true });\n\n\tcreate();\n\n\n## View your models\n\tmodef.printHierarchies();\n\n\n\tAuthor (root)\n\t `- Post\n\t |   `- Picture -> Post\n\t |   `- Comment\n\t `- Comment\n\t `- Picture\n\t     `- Post -> Picture\n\t         `- Comment\n\n\n## Use defined Mongoose Models\n\t// modef exports mongoose models\n\tvar post = new modef['Post']();\n\tpost.body = 'Lorem ipsum dolor sit amet, consectetur...';\n\tpost.save();\n\n\tvar author = new modef['Author']();\n\tauthor.name = 'John Author';\n\tauthor.username = 'john.author';\n\tauthor.posts.push(post);\n\tauthor.save();\n","maintainers":[{"name":"rouzwawi","email":"rouzwawi@gmail.com"}],"time":{"modified":"2022-06-20T02:49:11.245Z","created":"2011-11-15T14:15:56.567Z","0.1.0":"2011-11-15T14:15:58.262Z","0.1.1":"2012-03-31T19:52:17.876Z","0.1.2":"2012-05-06T22:40:41.064Z","0.1.3":"2012-08-12T00:45:17.112Z"},"author":{"name":"Rouzbeh Delavari","email":"rouzwawi@gmail.com"},"repository":{"type":"git","url":"git://github.com/rouzwawi/modef.git"},"users":{"dfl":true}}