code: function update(model) {
    var params = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  
    if (!model) {
      throw new Error('No model provided.');
    }
    var currentState = model.toJSON({ shallow: true });
    currentState.id = String(currentState.id);
  
    return _destructure2['default'](model, params).then(function (destructured) {
      var attributes = destructured.attributes;
      var relations = destructured.relations;
  
      return _transact2['default'](model, function (transaction) {
        return model.save(attributes, {
          patch: true,
          method: 'update',
          transacting: transaction
        }).tap(function (model) {
          return _relate2['default'](model, relations, 'update', transaction);
        }).then(function (model) {
          // if model didn't change, return null
          // model.previousAttributes() is broken.
          // https://github.com/tgriesser/bookshelf/issues/326
          var updatedState = model.toJSON({ shallow: true });
          updatedState.id = String(updatedState.id);
          return _lodash2['default'].isEqual(currentState, updatedState) ? null : model;
        });
      });
    });
  }
docs: Updates a model.
  
  @param {Bookshelf.Model} model - A bookshelf model instance
  @param {Object} params - An object containing the params from the request.
  @returns {Promise.Bookshelf.Model|null} -
  The updated model or null if nothing has changed.