0.7.5 • Published 9 years ago

koa-knex v0.7.5

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

koa-knex-middleware

NPM version Dependency Status

Knex.js Middleware for Koa. Package is versioned in step with http://knexjs.org/#changelog

0. Installation (via npm)

  $ npm install koa-knex --save

1. Usage (contrived example)

  var _ = require('koa-route');
  var knex = require('koa-knex');
  ...
  app.use(knex({
    client: 'pg',
    connection: {
      /** typical knex connection object */
    }
  });

  app.use(_.get('/:userid', function *(userid) {
    this.body = {
      profile: yield this.knex('users').where('id', userid);
    };
  });

2. Options

The following environment variables will be automatically used for the Knex.js connection object if set:

  KOA_KNEX_HOST
  KOA_KNEX_PORT
  KOA_KNEX_USER
  KOA_KNEX_PASSWORD
  KOA_KNEX_DATABASE
  KOA_KNEX_CHARSET
  KOA_KNEX_SSL
  KOA_KNEX_DEBUG

License

MIT

0.7.5

9 years ago

0.7.4

9 years ago

0.7.3

9 years ago

0.5.14

10 years ago

0.0.0

10 years ago

0.5.13

10 years ago