我是Node,Koa和Web开发的新手,我正在尝试将查询中的数据发送到模板。我正在使用Bookshelfjs作为ORM。
CellBeginEdit
答案 0 :(得分:0)
您需要使用他们的Promise
界面。我不确定findById
是什么,所以我会从他们的文档中修改一个例子。
module.exports = {
/** Get user info by id */
getId: function * getId (next) {
// assume User is a bookshelf model.
// probably userMng in your case, but it's hard to say without more code.
let user = yield User.where('id', this.params.id).fetch();
this.body = yield this.render('id', {
title: 'Show detailes about item: ' + this.params.id,
data: user
});
yield next;
}
};