问题描述
突然起身在我的日志函数这个错误,我无法弄清楚到底是什么原因造成的。我查了一下这两种情况下,我使用的查询或插入到MongoDB中,却看不到与参数中的任何问题。只需使用JSON在第一个参数,以及一个回调函数第二,我认为应该工作,似乎在我用它其它情况下工作。我想可能有语法错误(也许)或者一些可能会导致它。任何想法?结果
首先蒙戈用法:
Suddenly got this error in my log-in function and I can't figure out exactly what is causing it. I checked both cases where I use query or insert into MongoDB, but can't see any problems with the arguments. Just using json in the first argument, and a callback function in the second, which I think should work and seems to work in other cases where I use it. I think I may have syntax error(maybe) or something that might be causing it. Any ideas?
First Mongo usage:
this.validateLogin = function(username, password, callback){
"use strict";
users.findOne({'_id' :username }, function (err,user){
//some code
});
}
二蒙戈用法:
sessions.insert(session, function (err, result) {
"use strict";
callback(err, session_id);
});
下面是错误:
C:\...\node_modules\mongodb\lib\mongodb\connection\b
ase.js:242
throw message;
^
MongoError: Incorrect arguments
at Object.toError (C:\...\node_modules\mongodb\l
ib\mongodb\utils.js:110:11)
at Server.Base._callHandler (C:\...\node_modules
\mongodb\lib\mongodb\connection\base.js:444:65)
at C:\...\node_modules\mongodb\lib\mongodb\conne
ction\server.js:485:18
at MongoReply.parseBody (C:\...\node_modules\mon
godb\lib\mongodb\responses\mongo_reply.js:68:5)
at null.<anonymous> (C:\...\node_modules\mongodb
\lib\mongodb\connection\server.js:443:20)
at EventEmitter.emit (events.js:95:17)
at null.<anonymous> (C:\...\node_modules\mongodb
\lib\mongodb\connection\connection_pool.js:191:13)
at EventEmitter.emit (events.js:98:17)
at Socket.<anonymous> (C:\...\node_modules\mongo
db\lib\mongodb\connection\connection.js:418:22)
at Socket.EventEmitter.emit (events.js:95:17)
在此先感谢!
推荐答案
想通了!我看了看我得到了什么,当我手动走进蒙戈外壳,看看有什么我回来使用findOne('_ ID,名为myusername'),发现沿线某处我的密码是越来越删除(或更可能被覆盖别的东西)从文档,因而无法检索后导致错误不正确的参数。现在我只需要弄清楚的地方正在发生,并修复它!
Figured it out!! I looked at what I got when I manually went into the mongo shell to see what I got back using the findOne('_id', 'myusername') and discovered that somewhere along the line my password is getting deleted (or more likely overwritten by something else) from the document and thus cannot retrieve it later leading to the error "Incorrect arguments". Now I just need to figure out where that is happening and fix it!
这篇关于MongoError:不正确的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!