egg-bookshelf
v1.1.0
Published
eggjs's bookshelf plugin.
Downloads
6
Readme
egg-bookshelf
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.