koa-bookshelf

0.0.2 • Public • Published

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);

Readme

Keywords

Package Sidebar

Install

npm i koa-bookshelf

Weekly Downloads

1

Version

0.0.2

License

MIT

Last publish

Collaborators

  • xudong