1.1.0 • Published 6 years ago

egg-bookshelf v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago