0
我有如下的連接設置:找到()查詢
mongoose.connect('mongodb://127.0.0.1:27017/cpfdb');
var Schema = mongoose.Schema;
var definitionSchema = new Schema({
type: String,
term: String,
desccription: String
});
var Defintion = mongoose.model('Definition', definitionSchema);
module.exports = Defintion;
我做如下的查詢:
Defintion.find({term: 'cpf life'}, function (err, definition) {
if (err) {
session.send("Something went wrong with the mongoose query: " + err);
} else {
session.send("I will define " + termToDefine + " for you...");
session.send(definition);
}
});
不過,我不斷收到錯誤:
events.js:141
throw er; // Unhandled 'error' event
^
TypeError: key.replace is not a function
at DefaultLocalizer.escapeKey (/Users/user/Desktop/GitHub Projects/cpfbot/node_modules/botbuilder/lib/DefaultLocalizer.js:204:20)
at DefaultLocalizer.createKey (/Users/user/Desktop/GitHub Projects/cpfbot/node_modules/botbuilder/lib/DefaultLocalizer.js:196:33)
at DefaultLocalizer.trygettext (/Users/user/Desktop/GitHub Projects/cpfbot/node_modules/botbuilder/lib/DefaultLocalizer.js:69:24)
at DefaultLocalizer.gettext (/Users/user/Desktop/GitHub Projects/cpfbot/node_modules/botbuilder/lib/DefaultLocalizer.js:86:21)
at Session.vgettext (/Users/user/Desktop/GitHub Projects/cpfbot/node_modules/botbuilder/lib/Session.js:538:35)
at Session.createMessage (/Users/user/Desktop/GitHub Projects/cpfbot/node_modules/botbuilder/lib/Session.js:521:24)
at Session.sendLocalized (/Users/user/Desktop/GitHub Projects/cpfbot/node_modules/botbuilder/lib/Session.js:179:26)
at Session.send (/Users/user/Desktop/GitHub Projects/cpfbot/node_modules/botbuilder/lib/Session.js:168:48)
at /Users/user/Desktop/GitHub Projects/cpfbot/app.js:38:33
at Query.<anonymous> (/Users/user/Desktop/GitHub Projects/cpfbot/node_modules/mongoose/lib/model.js:3709:16)
at /Users/user/Desktop/GitHub Projects/cpfbot/node_modules/mongoose/node_modules/kareem/index.js:273:21
at /Users/user/Desktop/GitHub Projects/cpfbot/node_modules/mongoose/node_modules/kareem/index.js:127:16
at nextTickCallbackWith0Args (node.js:420:9)
at process._tickCallback (node.js:349:13)
我檢查了mongoldb外殼(不使用貓鼬)和查詢工作正常。我找不到任何信息key.replace is not a function
...
什麼是會話變量?和termToDefine變量?我改變了session.send到console.log和termToDefine來定義 - 那麼你的例子對我來說工作得很好。 –