Update model.js

Correct event docs per https://groups.google.com/forum/#!topic/loopbackjs/61qd--Xkowo:
 - `deleted` event takes instance arg, not id.
 - Add docs for `set` event
This commit is contained in:
Rand McKinney 2014-09-02 11:11:36 -07:00
parent 9b97014b52
commit 1af1ec2c43
1 changed files with 19 additions and 4 deletions

View File

@ -28,6 +28,7 @@ var stringUtils = require('underscore.string');
* #### Event: `changed`
*
* Emitted after a model has been successfully created, saved, or updated.
* Argument: `inst`, model instance, object
*
* ```js
* MyModel.on('changed', function(inst) {
@ -39,10 +40,11 @@ var stringUtils = require('underscore.string');
* #### Event: `deleted`
*
* Emitted after an individual model has been deleted.
* Argument: `id`, model ID (number).
*
* ```js
* MyModel.on('deleted', function(inst) {
* console.log('model with id %s has been deleted', inst.id);
* MyModel.on('deleted', function(id) {
* console.log('model with id %s has been deleted', id);
* // => model with id 1 has been deleted
* });
* ```
@ -50,11 +52,12 @@ var stringUtils = require('underscore.string');
* #### Event: `deletedAll`
*
* Emitted after an individual model has been deleted.
* Argument: `where` (optional), where filter, JSON object.
*
* ```js
* MyModel.on('deletedAll', function(where) {
* if(where) {
* console.log('all models where', where, 'have been deleted');
* console.log('all models where ', where, ' have been deleted');
* // => all models where
* // => {price: {gt: 100}}
* // => have been deleted
@ -70,6 +73,18 @@ var stringUtils = require('underscore.string');
*
* Emitted after a `Model` has been attached to a `DataSource`.
*
* #### Event: set
*
* Emitted when model property is set.
* Argument: `inst`, model instance, object
*
* ```js
* MyModel.on('set', function(inst) {
* console.log('model with id %s has been changed', inst.id);
* // => model with id 1 has been changed
* });
* ```
*
* @class
* @param {Object} data
* @property {String} modelName The name of the model