create(body, userId = null) {
    return this.checkAndClean(body, true)
      .then(result => {
        if (result.ok) {
          // everything ok, lets store the cleaned data, if it's not ok, return the error list found by checkAndClean.
          const document = {
            _id: this.yggdrasil.uuid(true),
            body: result.body,
            meta: this._createDocumentMeta(userId)
          };
          return this.set(document);
        }
        let error = new Error('Requirements not met according to the model.');
        error.errors = result.errors;
        return Bluebird.reject(error);
      });
  }
/**
   * Create a new Object for this repository after having checked it against its model and eventually reformatted its data.
   * @param body
   * @param userId
   * @returns {*}
   */
Create a new Object for this repository after having checked it against its model and eventually reformatted its data.
@param body
@param userId
@returns {*}
Create a new Object for this repository after having checked it against its model and eventually reformatted its data . @param body @param userId @returns { * }
create(body, userId = null) {
    return this.checkAndClean(body, true)
      .then(result => {
        if (result.ok) {
          const document = {
            _id: this.yggdrasil.uuid(true),
            body: result.body,
            meta: this._createDocumentMeta(userId)
          };
          return this.set(document);
        }
        let error = new Error('Requirements not met according to the model.');
        error.errors = result.errors;
        return Bluebird.reject(error);
      });
  }
create ( body , userId = null ) { return this . checkAndClean ( body , true ) . then ( result => { if ( result . ok ) { const document = { _id : this . yggdrasil . uuid ( true ) , body : result . body , meta : this . _createDocumentMeta ( userId ) } ; return this . set ( document ) ; } let error = new Error ( 'Requirements not met according to the model.' ) ; error . errors = result . errors ; return Bluebird . reject ( error ) ; } ) ; }
Create a new Object for this repository after having checked it against its model and eventually reformatted its data.
Create a new Object for this repository after having checked it against its model and eventually reformatted its data .
// everything ok, lets store the cleaned data, if it's not ok, return the error list found by checkAndClean.