我查看了这里的每篇文章,但没有任何匹配。
使用最新资源
"mongoose": "^4.8.1"
"bluebird": "^3.4.7"
使用蓝鸟的猫鼬方式
mongoose.Promise = require('bluebird');
错误发生在" respHelper.resp ..."呼叫 Trader.Model是mongoose模型的地方" TraderModel = mongoose.model(' Trader',Trader);"
TraderModel.findOne({_id: req.account.traderid})
.then(function(trader) {
respHelper.resp(200, res, {trader: trader});
return null
})
.catch(function(error) {
eLogger.error("Could not get Trader", ERRORS.ERR_DATABASEERROR, [], {accountid: req.account._id, traderid: req.params.traderid, exception: error});
respHelper.respErr(500, res, ERRORS.ERR_DATABASEERROR);
return null;
});
完整堆栈跟踪:
(node:11912) Warning: a promise was created in a handler but was not returned from it, see goo.gl/rRqMUw
at new Promise (d:\Projects\work\UCConnectAPI\server\node_modules\bluebird\js\release\promise.js:77:14)
at Model.compile.model.Query.exec (d:\Projects\work\UCConnectAPI\server\node_modules\mongoose\lib\query.js:2536:17)
at Model.compile.model.Query.Query.then (d:\Projects\work\UCConnectAPI\server\node_modules\mongoose\lib\query.js:2584:15)
at module.exports.getTraderByAccount (d:\Projects\work\UCConnectAPI\server\app\controllers\controller_api_trader.js:25:4)
at Layer.handle [as handle_request] (d:\Projects\work\UCConnectAPI\server\node_modules\express\lib\router\layer.js:95:5)
at next (d:\Projects\work\UCConnectAPI\server\node_modules\express\lib\router\route.js:131:13)
at Route.dispatch (d:\Projects\work\UCConnectAPI\server\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (d:\Projects\work\UCConnectAPI\server\node_modules\express\lib\router\layer.js:95:5)
at d:\Projects\work\UCConnectAPI\server\node_modules\express\lib\router\index.js:277:22
at Function.process_params (d:\Projects\work\UCConnectAPI\server\node_modules\express\lib\router\index.js:330:12)
at next (d:\Projects\work\UCConnectAPI\server\node_modules\express\lib\router\index.js:271:10)
at d:\Projects\work\UCConnectAPI\server\app\lib\apitokenmanager.js:59:9
at runCallback (timers.js:649:20)
at tryOnImmediate (timers.js:622:5)
at processImmediate [as _immediateCallback] (timers.js:594:5)
From previous event:
at d:\Projects\work\UCConnectAPI\server\app\lib\apitokenmanager.js:53:43
at d:\Projects\work\UCConnectAPI\server\node_modules\jsonwebtoken\verify.js:27:18
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
编辑:添加了TraderModel
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var Trader = new Schema({
// Trader profile datas
companyName: String,
ustIdent: String,
plz: String,
city: String,
country: String,
street: String,
streetNumber: String,
contactPersonTechnical: String,
contactPersonBilling: String,
email: String,
// Accounts für den Trader
accounts: [
{
accountid: {type: Schema.Types.ObjectId, ref: 'Account'},
// Rechte
rights: {
allowAddAccount: Boolean
}
}
],
// Kunden des Traders
customerids: [{type: Schema.Types.ObjectId, ref: 'Customer', index: true}],
// Sub-Trader (untergeordnet)
traderids: [{type: Schema.Types.ObjectId, ref: 'Trader', index: true}],
// Haupttrader (übergeordnet)
traderid: {type: String, trim: true, index: {unique: true}},
created: {type: Date, default: Date.now()}, // im system angelegt am....
changed: {type: Date, default: Date.now(), index: true} // geändet am...
});
Trader.set('toJSON', {getters: true, virtuals: false, depopulate: true});
Trader.methods.filterForPublic = function() {
var tmpJson = this.toJSON();
var publicData = {
id: tmpJson._id,
traderid: tmpJson.traderid,
companyName: tmpJson.companyName,
ustIdent: tmpJson.ustIdent,
plz: tmpJson.plz,
city: tmpJson.city,
street: tmpJson.street,
streetNumber: tmpJson.streetNumber,
country: tmpJson.country,
contactPersonTechnical: tmpJson.contactPersonTechnical,
contactPersonBilling: tmpJson.contactPersonBilling
};
return publicData;
};
var TraderModel = mongoose.model('Trader', Trader);
答案 0 :(得分:0)
很抱歉盲目看到:/
原因在一个完全不同的地方。 Shoudl在堆栈跟踪方面看起来更好。
从上一次活动开始: 在d:\ Projects \ work \ UCConnectAPI \ server \ app \ lib \ apitokenmanager.js:53:43 在d:\ Projects \ work \ UCConnectAPI \ server \ node_modules \ jsonwebtoken \ verify.js:27:18