egg-knex-promise

1.0.6 • Public • Published

egg-knex

NPM version build status Test coverage Known Vulnerabilities npm download

knex plugin for egg

Install

$ npm i egg-knex-promise --save

Usage

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

Configuration

// {app_root}/config/config.default.js
exports.knex = {
      client: 'sqlite3',
      connection: {
        filename: './test.db3',
      },
};

see Knex.js for more detail.

Example

// {app_root}/controller/home.js
class HomeController extends Controller {
    async index() {
        const data = await this.app.knex('user').select('*');
        this.ctx.body = data;
    }
}

Questions & Suggestions

Please open an issue here.

License

MIT

Package Sidebar

Install

npm i egg-knex-promise

Weekly Downloads

7

Version

1.0.6

License

MIT

Unpacked Size

7.77 kB

Total Files

7

Last publish

Collaborators

  • hankexu