项目作者: hankexu

项目描述 :
knex plugin for egg
高级语言: JavaScript
项目地址: git://github.com/hankexu/egg-knex.git
创建时间: 2018-12-21T06:31:36Z
项目社区:https://github.com/hankexu/egg-knex

开源协议:MIT License

下载


egg-knex

NPM version
build status
Test coverage
Known Vulnerabilities
npm download

knex plugin for egg

Install

  1. $ npm i egg-knex-promise --save

Usage

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

Configuration

  1. // {app_root}/config/config.default.js
  2. exports.knex = {
  3. client: 'sqlite3',
  4. connection: {
  5. filename: './test.db3',
  6. },
  7. };

see Knex.js for more detail.

Example

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

Questions & Suggestions

Please open an issue here.

License

MIT