【发布时间】:2018-05-29 03:43:32
【问题描述】:
我正在做一个大学项目,我已经阅读了所有关于我的问题的帖子,但我还没有找到解决方案。也许你能帮帮我。
代码如下:
viewerObj.update({_id: currentIDViewerVar} , {minutesWatched: 5},{upsert:true} , function (err,result) {
if (err) throw err;
console.log("Viewer " + userNameVar + " gespeichert");
console.log("minsWatched" +minsWatched);
});
我收到以下错误。我看不出我做错了什么。
events.js:160
throw er; // Unhandled 'error' event
^
TypeError: callback.apply is not a function
at C:\Users\picco\Desktop\TwitchWatcher_v19\TwitchWatcher\node_modules\mongoose\lib\model.js:3388:16
at Query.callback (C:\Users\picco\Desktop\TwitchWatcher_v19\TwitchWatcher\node_modules\mongoose\lib\query.js:2185:9)
at C:\Users\picco\Desktop\TwitchWatcher_v19\TwitchWatcher\node_modules\mongoose\node_modules\kareem\index.js:259:21
at C:\Users\picco\Desktop\TwitchWatcher_v19\TwitchWatcher\node_modules\mongoose\node_modules\kareem\index.js:127:16
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
Process finished with exit code 1
提前谢谢你!
【问题讨论】:
-
update方法必须遵循参数:update(doc, options, callback)。你传递了一个额外的对象。 -
我对 mongodb 一无所知,但我查看了
update()的一些文档,看来您使用它确实不正确。那么,您是否查看了您正在使用的方法的文档?
标签: javascript node.js mongodb mongoose