diff --git a/lib/dao.js b/lib/dao.js index 3a4ebfed..267d609e 100644 --- a/lib/dao.js +++ b/lib/dao.js @@ -209,6 +209,7 @@ function stillConnecting(dataSource, obj, args) { /** * Update or insert a model instance. + * `updateOrCreate` is an alias * @param {Object} data The model instance data * @param {Function} callback The callback function (optional). */ @@ -470,7 +471,6 @@ DataAccessObject._coerce = function (where) { * - limit: Number * - skip: Number * - * @param {Object} params (optional) * @param {Function} callback (required) called with two arguments: err (null or Error), array of instances */ @@ -628,9 +628,7 @@ setRemoting(DataAccessObject.findOne, { * @param {Object} [where] An object that defines the criteria * @param {Function} [cb] Callback called with (err) */ -DataAccessObject.remove = - DataAccessObject.deleteAll = - DataAccessObject.destroyAll = function destroyAll(where, cb) { +DataAccessObject.remove = DataAccessObject.deleteAll = DataAccessObject.destroyAll = function destroyAll(where, cb) { if (stillConnecting(this.getDataSource(), this, arguments)) return; var Model = this; @@ -655,13 +653,13 @@ DataAccessObject.remove = }; /** - * Destroy a record by id + * Delete the record with the specified ID. + * Aliases are `destroyById` and `deleteById`. * @param {*} id The id value * @param {Function} cb Callback called with (err) */ -DataAccessObject.removeById = - DataAccessObject.deleteById = - DataAccessObject.destroyById = function deleteById(id, cb) { + +DataAccessObject.removeById = DataAccessObject.deleteById = DataAccessObject.destroyById = function deleteById(id, cb) { if (stillConnecting(this.getDataSource(), this, arguments)) return; var Model = this; @@ -708,10 +706,12 @@ setRemoting(DataAccessObject.count, { }); /** - * Save instance. When instance haven't id, create method called instead. - * Triggers: validate, save, update | create - * @param options {validate: true, throws: false} [optional] - * @param callback(err, obj) + * Save instance. If the instance does not have an ID, call `create` instead. + * Triggers: validate, save, update or create. + * @options {Object} options Optional options to use. + * @property {Boolean} validate Default is true. + * @property {Boolean} throws Default is false. + * @param {Function} callback Callback function with err and object arguments */ DataAccessObject.prototype.save = function (options, callback) { if (stillConnecting(this.getDataSource(), this, arguments)) return; @@ -821,9 +821,8 @@ DataAccessObject.prototype.remove = }; /** - * Update single attribute - * - * equals to `updateAttributes({name: value}, cb) + * Update a single attribute. + * Equivalent to `updateAttributes({name: value}, cb)` * * @param {String} name Name of property * @param {Mixed} value Value of property @@ -836,9 +835,8 @@ DataAccessObject.prototype.updateAttribute = function updateAttribute(name, valu }; /** - * Update set of attributes - * - * this method performs validation before updating + * Update saet of attributes. + * Performs validation before updating. * * @trigger `validation`, `save` and `update` hooks * @param {Object} data Data to update