bluebird with mongoose, TypeError: .create(...).then(...).nodeify is not a function
bluebird with mongoose, TypeError: .create(...).then(...).nodeify is not a function
我正在尝试在猫鼬中使用蓝鸟。但是遇到一些问题:
我写了一些bluebird的测试代码,里面没有用到mongoose。就像这样:
A().then().error().catch().nodeify() ....
而且有效。
但是当我使用mongoose操作时,出现错误。
只是一个像这样的演示代码:
Username.create().then().nodeify() ...
类型错误:.create().then().nodeify 不是一个函数。
(我也试过asCallback,也不行,同样的错误)
如果在其中使用error(),也会出现同样的错误:
Username.create().then().error().nodeify() ...
TypeError: .create().then().error is not a function
(用户名是猫鼬模型)
我确定里面有蓝鸟。
var mongoose = require('mongoose');
var P = mongoose.promise = require('bluebird');
所以问题出在哪里???
是<a href="http://mongoosejs.com/docs/promises.html#plugging-in-your-own-promises-library" rel="nofollow">mongoose.Promise</a> = require('bluebird');
,不是mongoose.promise
.
我正在尝试在猫鼬中使用蓝鸟。但是遇到一些问题:
我写了一些bluebird的测试代码,里面没有用到mongoose。就像这样:
A().then().error().catch().nodeify() ....
而且有效。
但是当我使用mongoose操作时,出现错误。
只是一个像这样的演示代码:
Username.create().then().nodeify() ...
类型错误:.create().then().nodeify 不是一个函数。
(我也试过asCallback,也不行,同样的错误)
如果在其中使用error(),也会出现同样的错误:
Username.create().then().error().nodeify() ...
TypeError: .create().then().error is not a function
(用户名是猫鼬模型)
我确定里面有蓝鸟。
var mongoose = require('mongoose');
var P = mongoose.promise = require('bluebird');
所以问题出在哪里???
是<a href="http://mongoosejs.com/docs/promises.html#plugging-in-your-own-promises-library" rel="nofollow">mongoose.Promise</a> = require('bluebird');
,不是mongoose.promise
.