Choose the name of the exported function the way you want. It doesn't matter at all. You can also specify multiple models in one file. The _import_ method will return a hash, which stores the result of _sequelize.define_ under the key _Project_.
## Creation and deletion of class tables ##
## Creation and deletion of class tables ##
...
@@ -106,6 +121,24 @@ Now lets change some values and save changes to the database... There are two wa
...
@@ -106,6 +121,24 @@ Now lets change some values and save changes to the database... There are two wa
title: 'a very different title now'
title: 'a very different title now'
}, function(){})
}, function(){})
## Expanding models ##
Sequelize allows you to pass custom class and instance methods. Just do the following:
var Foo = sequelize.define('Foo', { /* attributes */}, {
classMethods: {
method1: function(){ return 'smth' }
},
instanceMethods: {
method2: function() { return 'foo' }
}
})
// ==>
Foo.method1()
new Foo({}).method2()
## Chain queries ##
## Chain queries ##
Because you will want to save several items at once and just go on after all of them are saved, Sequelize provides a handy helper for that:
Because you will want to save several items at once and just go on after all of them are saved, Sequelize provides a handy helper for that: