koa orm using sequelize & squel.
$ npm install koa-orm
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
configs
: Multi database config array.
MIT