update(document, userId = null) {
    return this.checkAndClean(document.body, false)
      .then(result => {
        // everything is ok, lets store the cleaned data, if it's not ok, return the error list found by checkAndClean.
        if (result.ok) {
          const _document = {
            _id: document._id,
            body: result.body,
            meta: this._createDocumentMeta(userId, document.meta || {})
          };
          return this.set(_document);
        }
        let error = new Error('Requirements not met according to the model.');
        error.errors = result.errors;
        return Bluebird.reject(error);
      });
  }
/**
   * Update an object for this repository after having checked it against its model.
   * Its almost the same as create but it wont avoid the creation if some duplicates values are found,
   * if the found duplicates are the object itself
   * @param document
   * @param userId
   * @returns {*|PromiseLike<T | never>|Promise<T | never>}
   */
Update an object for this repository after having checked it against its model.
Its almost the same as create but it wont avoid the creation if some duplicates values are found,
if the found duplicates are the object itself
@param document
@param userId
@returns {*|PromiseLike|Promise}
Update an object for this repository after having checked it against its model . Its almost the same as create but it wont avoid the creation if some duplicates values are found if the found duplicates are the object itself @param document @param userId @returns { * |PromiseLike|Promise }
update(document, userId = null) {
    return this.checkAndClean(document.body, false)
      .then(result => {
        if (result.ok) {
          const _document = {
            _id: document._id,
            body: result.body,
            meta: this._createDocumentMeta(userId, document.meta || {})
          };
          return this.set(_document);
        }
        let error = new Error('Requirements not met according to the model.');
        error.errors = result.errors;
        return Bluebird.reject(error);
      });
  }
update ( document , userId = null ) { return this . checkAndClean ( document . body , false ) . then ( result => { if ( result . ok ) { const _document = { _id : document . _id , body : result . body , meta : this . _createDocumentMeta ( userId , document . meta || { } ) } ; return this . set ( _document ) ; } let error = new Error ( 'Requirements not met according to the model.' ) ; error . errors = result . errors ; return Bluebird . reject ( error ) ; } ) ; }
Update an object for this repository after having checked it against its model.
Update an object for this repository after having checked it against its model .
// everything is ok, lets store the cleaned data, if it's not ok, return the error list found by checkAndClean.