Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added MIT license

  • Loading branch information...
commit 1ad3a79fcbe9a3d99ccde27cb91e4807357677eb 1 parent 5e5c020
Henrik Kjelsberg authored
Showing with 42 additions and 3 deletions.
  1. +33 −0 Readme.md
  2. +9 −3 crud.js
33 Readme.md
View
@@ -19,3 +19,36 @@ __Crud functionality for mongoose-models. Fits well with express.js__
app.get('/crud/:model', crud, function (req, res) {
res.render('crud')
})
+
+
+## Constributors
+
+* Henrik Kjelsberg <hkjels@me.com>
+[github](http://github.com/hkjels/ "Github account")
+[website](http://take.no/ "Development blog")
+
+
+## License
+
+> (The MIT License)
+>
+> Copyright (c) 2012 Henrik Kjelsberg &lt;henrik@kjelsberg.net&gt;
+>
+> Permission is hereby granted, free of charge, to any person obtaining
+> a copy of this software and associated documentation files (the
+> 'Software'), to deal in the Software without restriction, including
+> without limitation the rights to use, copy, modify, merge, publish,
+> distribute, sublicense, and/or sell copies of the Software, and to
+> permit persons to whom the Software is furnished to do so, subject to
+> the following conditions:
+>
+> The above copyright notice and this permission notice shall be
+> included in all copies or substantial portions of the Software.
+>
+> THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+> CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+> TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+> SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 crud.js
View
@@ -1,4 +1,10 @@
+/*!
+ * Crud
+ * Copyright (c) Henrik Kjelsberg 2012 <henrik@kjelsberg.net>
+ * MIT licensed
+ */
+
/**
* Module dependencies
*/
@@ -10,8 +16,8 @@ var mongoose = require('mongoose')
* Simplify
*
* Normalizes a mongoose Schema to be used with a template
- * @param {String} model Name of the mongoose model
- * @param {Function} cb Callback
+ * @param {Mixed} model Model or name of a model
+ * @param {Function} cb Callback
*/
var simplify = exports.simplify = function (model, cb) {
@@ -24,7 +30,7 @@ var simplify = exports.simplify = function (model, cb) {
*/
try {
- Model = mongoose.model(model)
+ Model = typeof model === 'string' ? mongoose.model(model) : model
Schema = cycle.decycle(Model.prototype._schema.paths)
}
Please sign in to comment.
Something went wrong with that request. Please try again.