es5/store-bookshelf/lib/create.js
function create(model) {
  var params = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

  if (!model) {
    throw new Error('No model provided.');
  }
  return _destructure2['default'](model.forge(), params).then(function (destructured) {
    var attributes = destructured.attributes;
    var relations = destructured.relations;

    return _transact2['default'](model, function (transaction) {
      return model.forge(attributes).save(null, {
        method: 'insert',
        transacting: transaction
      }).tap(function (newModel) {
        return _relate2['default'](newModel, relations, 'create', transaction);
      }).then(function (newModel) {
        return model.forge({ id: newModel.id }).fetch({ transacting: transaction });
      });
    });
  });
}
function create(model) {
  var params = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

  if (!model) {
    throw new Error('No model provided.');
  }
  return _destructure2['default'](model.forge(), params).then(function (destructured) {
    var attributes = destructured.attributes;
    var relations = destructured.relations;

    return _transact2['default'](model, function (transaction) {
      return model.forge(attributes).save(null, {
        method: 'insert',
        transacting: transaction
      }).tap(function (newModel) {
        return _relate2['default'](newModel, relations, 'create', transaction);
      }).then(function (newModel) {
        return model.forge({ id: newModel.id }).fetch({ transacting: transaction });
      });
    });
  });
}
function create ( model ) { var params = arguments . length <= 1 || arguments [ 1 ] === undefined ? { } : arguments [ 1 ] ; if ( ! model ) { throw new Error ( 'No model provided.' ) ; } return _destructure2 [ 'default' ] ( model . forge ( ) , params ) . then ( function ( destructured ) { var attributes = destructured . attributes ; var relations = destructured . relations ; return _transact2 [ 'default' ] ( model , function ( transaction ) { return model . forge ( attributes ) . save ( null , { method : 'insert' , transacting : transaction } ) . tap ( function ( newModel ) { return _relate2 [ 'default' ] ( newModel , relations , 'create' , transaction ) ; } ) . then ( function ( newModel ) { return model . forge ( { id : newModel . id } ) . fetch ( { transacting : transaction } ) ; } ) ; } ) ; } ) ; }
Creates 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} The created model.
Creates a model .