egg-bookshelf

1.1.0 • Public • Published

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

Package Sidebar

Install

npm i egg-bookshelf

Weekly Downloads

2

Version

1.1.0

License

MIT

Unpacked Size

12.2 kB

Total Files

9

Last publish

Collaborators

  • tujiao