Skip to content

arden/egg-bookshelf

Repository files navigation

egg-bookshelf

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Install

$ npm i egg-bookshelf --save

Usage

// {app_root}/config/plugin.js
exports.bookshelf = {
  enable: true,
  package: 'egg-bookshelf',
};

Transaction

egg-knex support manual/auto commit.

Manual commit

const trx = yield app.knex.transaction();
try {
  yield trx.insert(row1).into('table');
  yield trx('table').update(row2);
  yield trx.commit()
} catch (e) {
  yield trx.rollback();
  throw e;
}

Auto commit

const result = yield app.knex.transaction(function* transacting (trx) {
  yield trx(table).insert(row1);
  yield trx(table).update(row2).where(condition);
  return { success: true };
});

Configuration

// {app_root}/config/config.default.js
exports.bookshelf = {
};

see config/config.default.js for more detail.

Example

Questions & Suggestions

Please open an issue here.

License

MIT

Releases

No releases published

Packages

No packages published