{"_id":"destrruc","_rev":"5-181e67aa534e05a28883a0ce2a083c6d","name":"destrruc","description":"HTTP Restful interface in express for mongoose models defined using modef","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"author":{"name":"Rouzbeh Delavari","email":"rouzwawi@gmail.com"},"name":"destrruc","description":"HTTP Restful interface in express for mongoose models defined using modef","version":"0.1.0","repository":{"type":"git","url":"git://github.com/rouzwawi/destrruc.git"},"main":"index","engines":{"node":"~0.6.0"},"dependencies":{"tamejs":">= 0.4.5"},"devDependencies":{"modef":"~ 0.1.0"},"_npmUser":{"name":"rouzwawi","email":"rouzwawi@gmail.com"},"_id":"destrruc@0.1.0","_engineSupported":true,"_npmVersion":"1.0.105","_nodeVersion":"v0.6.1","_defaultsLoaded":true,"dist":{"shasum":"1e56bf4949df603ffa658e6a47cf3973ab41998b","tarball":"https://registry.npmjs.org/destrruc/-/destrruc-0.1.0.tgz","integrity":"sha512-o4weqDDsure1r2Q3CznJzFFytPsjqbXTIwn+tYelCOLv2yUN8mOFH5FNIzLd5hRB/sQ3wI5sze4IxjWWJdjG7w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDZiFENxJvIeRzszzm8kxf/jtddav6X7Y38DNN76DcKdAIgft8YUMvHQCZF1LJJE7qOKAaDsZu92Ob2oduaidj+U/k="}]},"maintainers":[{"name":"rouzwawi","email":"rouzwawi@gmail.com"}]}},"readme":"# 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() on 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.author\n\tGET     /:model/:id  ->  Return Model :id as JSON\n\tPUT     /:model/:id  ->  Update Model :id to req.body.author (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.\nThis is the default behavior.\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\nA callback function for rendering the entity\n\n### id\nA 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","maintainers":[{"name":"rouzwawi","email":"rouzwawi@gmail.com"}],"time":{"modified":"2022-06-15T01:50:02.811Z","created":"2011-11-15T23:23:35.450Z","0.1.0":"2011-11-15T23:23:37.253Z"},"author":{"name":"Rouzbeh Delavari","email":"rouzwawi@gmail.com"},"repository":{"type":"git","url":"git://github.com/rouzwawi/destrruc.git"}}