나는 여기에서 모든 게시물을 보았지만 일치하는 것이 없습니다.
최신 소스 사용
"mongoose": "^4.8.1"
"bluebird": "^3.4.7"
몽구스 방식으로 블루 버드 사용하기
mongoose.Promise = require('bluebird');
"respHelper.resp ..."호출 전에 오류가 발생합니다. 여기서 Trader.Model은 몽구스 모델입니다. "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);
눈이 멀어서 죄송합니다 : /
원인은 완전히 다른 곳에있었습니다. Shoudl은 스택 추적을 더 잘 보았습니다.
이전 이벤트에서 : d : \ Projects \ work \ UCConnectAPI \ server \ app \ lib \ apitokenmanager.js : 53 : 43에서 d : \ Projects \ work \ UCConnectAPI \ server \ node_modules \ jsonwebtoken \ verify.js : 27 : 18
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다