UNPKG

mongorilla

Version:

Mongorilla is a simple, clean, and powerful NodeJS based content moderator for MongoDB.

26 lines (23 loc) 1.21 kB
define('model/<%= collection.name %>', [ <%= _(collection.relations).filter(function (relation) { return 'fs.files' !== relation.relatedCollection; }).map(function (relation, key) { return '\'model/' + relation.relatedCollection + '\''; }).join(', ') %> ], function ( <%= _(collection.relations).filter(function (relation) { return 'fs.files' !== relation.relatedCollection; }).map(function (relation, key) { return relation.relatedCollection.toCamelCase(); }).join(', ') %> ) { <% var schema = {}; %> Backbone.Model.<%= collection.name.toCamelCase() %> = Backbone.DeepModel.extend({ idAttribute: '_id', urlRoot: '/api/<%= collection.name %>', defaults: <%= JSON.stringify(collection.backboneForms.defaults||{}) %>, schema: <%= global.helpers.stringify(schema) %>, toString: function () { <% if (collection.toStringField) { %> return this.get('<%= collection.toStringField %>'); <% } else { %> return 'Missing config setting: collection.toStringField must be set'; <% } %> } }); return Backbone.Model.<%= collection.name.toCamelCase() %>; });