-1
,同时运行在Node.js的下面的代码,我发现了错误: 类型错误:接下来是不是一个函数接下来是不是一个函数
function lastmessage(collection, path, conf, conf2, next) {
let tmp = conf === 0 ? hotelcode : parseInt(hotelcode);
db.collection(collection).find({
[path]: tmp
}).sort({
'created_at': -1
}).toArray(function(error, docs) {
if (error) return next(error);
if (docs.length > 0) {
if (conf2 === 0) {
console.log(docs[0].updatedAt);
return next(null, docs[0].updatedAt);
}
console.log(docs[0].created_at);
return next(null, docs[0].created_at);
}
console.log('empty');
return next(null, 'empty');
});
}
我在做什么错?
接下来是什么?你怎么调用'lastmessage',听起来像你没有提供'next'的回调 – ste2425
我认为这看起来很明显:你传递给这个函数的第五个参数不是函数 –
所以,我假设'next'是你的回调函数,所以在调用'lastmessage'的地方,你需要为它提供一个回调函数。 – Rowland