Models are defined using schemas with a very similar syntax to the one used in Mongoose, a popular MongoDB ORM.
The best practice when working with models is to put every model in its own file and in models.js aggregate all models in one object for easy export to clients and servers. Place them under:
myapp/app/models
Both clients and server will have access to the model classes, so you only need to define them in one place.
Check for example in app/models/animal.js:
define(['gnd'], function(Gnd){
var AnimalSchema = new Gnd.Schema({
name: {type: String},
desc: {type: String},
legs: {type: Number, max: 4, min: 2}
});
return Gnd.Model.extend('animals', AnimalSchema);
})
Define Routes