knex plugin for egg
$ npm i egg-knex-promise --save
// {app_root}/config/plugin.js
exports.knex = {
enable: true,
package: 'egg-knex-promise',
};
// {app_root}/config/config.default.js
exports.knex = {
client: 'sqlite3',
connection: {
filename: './test.db3',
},
};
see Knex.js for more detail.
// {app_root}/controller/home.js
class HomeController extends Controller {
async index() {
const data = await this.app.knex('user').select('*');
this.ctx.body = data;
}
}
Please open an issue here.