Update README.md

This commit is contained in:
mhupman 2013-04-08 12:20:46 -03:00
parent 3364102771
commit e2a9fc9995
1 changed files with 13 additions and 9 deletions

View File

@ -238,8 +238,8 @@ The following callbacks supported:
- afterUpdate
- beforeDestroy
- afterDestroy
- beforeValidation
- afterValidation
- beforeValidate
- afterValidate
Each callback is class method of the model, it should accept single argument: `next`, this is callback which
should be called after end of the hook. Except `afterInitialize` because this method is syncronous (called after `new Model`).
@ -249,19 +249,21 @@ should be called after end of the hook. Except `afterInitialize` because this me
```javascript
var user = new User;
// afterInitialize
user.save(callback);
// beforeValidation
// afterValidation
user.save(callback); // If Model.id isn't set, save will invoke Model.create() instead
// beforeValidate
// afterValidate
// beforeSave
// beforeCreate
// afterCreate
// beforeUpdate
// afterUpdate
// afterSave
// callback
user.updateAttribute('email', 'email@example.com', callback);
// beforeValidate
// afterValidate
// beforeSave
// beforeUpdate
// beforeValidation
// afterValidation
// afterUpdate
// afterSave
// callback
user.destroy(callback);
// beforeDestroy
@ -271,6 +273,8 @@ User.create(data, callback);
// beforeValidate
// afterValidate
// beforeCreate
// beforeSave
// afterSave
// afterCreate
// callback
```