index.js
/**
   * Updates an existing object with the given data.
   *
   * @param  {Number}  id - The object id
   * @param  {Object}  data - The fields to be updated
   * @return {Promise} Resolved with the old object or rejected with an error.
   */
Updates an existing object with the given data.
@param  {Number}  id - The object id
@param  {Object}  data - The fields to be updated
@return {Promise} Resolved with the old object or rejected with an error.
Updates an existing object with the given data . @param { Number } id - The object id @param { Object } data - The fields to be updated @return { Promise } Resolved with the old object or rejected with an error .
async update (id, data) {
    let el
    try {
      el = await this.list(id)
      await this.model.update({
        _id: id
      }, data, {
        runValidators: true
      }).exec()
      return el
    } catch (err) {
      if (!el) throw err
      const error = new Error('Invalid data')
      error.status = 400
      error.data = {
        [err.path]: err.message
      }
      throw error
    }
  }
async update ( id , data ) { let el try { el = await this . list ( id ) await this . model . update ( { _id : id } , data , { runValidators : true } ) . exec ( ) return el } catch ( err ) { if ( ! el ) throw err const error = new Error ( 'Invalid data' ) error . status = 400 error . data = { [ err . path ] : err . message } throw error } }
Updates an existing object with the given data.
Updates an existing object with the given data .