0.0.2 • Published 7 years ago

koa-bookshelf v0.0.2

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

koa-bookshelf

const Koa = require('koa');
const bookshelf = require('koa-bookshelf');

const app = new Koa();

app.use(bookshelf('/app/models', {
  client: 'mysql',
  connection: {
    host : 'localhost',
    user : 'root',
    password : '',
    database : 'blog'
  }
}));

app.use(async function (ctx, next) {
  const User = ctx.models.User;
  var users = await User.where({}).fetchAll();

  ctx.body = users;
});

app.listen(3000);