我有一个基于koa的应用程序,我想将数据写入nedb。 这个问题在下面的短片段中显示。 app.use(router.get('/', function*(){
db.insert(doc, function(err,data){
// can't yield here because the callback is not a generator
}
}));
我正在使用koa路由器来定义一个REST api。 我有一个途径,允许客户端补丁数据,为了这个,我希望只用响应: - OK - 发生错误 - 没有错误 或 NOT OK修补数据。 router.patch('/api/data', function *(next) {
if (_.has(this.query, 'id')) {
// do data patch