JeysonMontenegro / koa-orm

koa orm using sequelize & squel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

koa-orm

NPM version Dependency Status Build Status Coverage Status

koa orm using sequelize & squel.

Installation

$ npm install koa-orm

Example

var join = require('path').join;
var config = {
  modelPath: join(__dirname, 'models'),
  db: 'orm_test',
  username: 'root',
  password: 'pass',
  dialect: 'mysql',
  host: '127.0.0.1',
  port: 3306,
  pool: {
    maxConnections: 10,
    minConnections: 0,
    maxIdleTime: 30000
  }
};

var orm = require('koa-orm')(config);

app.use(orm.middleware);

app.use(function* (next) {
  var raws = yield this.orm().sql.select().from('table').query();
  // var raws = yield this.orm('orm_test').sql.select().from('table').query();
  this.body = raws;
});

More examples: test

API

orm(configs)

  • configs: Multi database config array.

License

MIT

About

koa orm using sequelize & squel


Languages

Language:JavaScript 100.0%