我在 KOA 上运行,并且由于 mass.js 回调性质试图对其进行 thunkify。这是我所拥有的:
Subcontractor.prototype.load = function () {
var findOne = thunkify(db.subcontractors.findOne);
co(function *() {
try {
var res = yield findOne({id:this.id});
} catch (err) {
console.log(err);
}
console.log(res);
})();
}
代码失败并出现以下错误(这是从 catch 块内部打印的):
[TypeError: this.find is not a function]
我知道,我还没有对结果做任何有意义的事情,我现在只想打印出结果。任何提示我做错了什么?