gpt4 book ai didi

node.js - 蒙戈错误: Can't canonicalize query: BadValue >1

转载 作者:太空宇宙 更新时间:2023-11-03 22:54:47 25 4
gpt4 key购买 nike

晚上好,

我一直忙于 Mongoosejs + Node.js,目前遇到以下错误。

[Login-01][ERROR] MongoError: Can't canonicalize query: BadValue >1 field in obj: { 
_events: {}, _posts: { save: [] }, _pres: { save: [] }, _doc: { _id:
ObjectId('537a652e88d1ff281aa9ce95'), name: "Diamondo25", banResetDate: null,
creationDate: new Date(1400530222052), female: null, isAdmin: false, __v: 0, password:
"---", salt: "---" }, _maxListeners: 0, errors: null, isNew: false, $__: { fullPath:
null, ownerDocument: null, activePaths: { stateNames: [ "require", "modify", "init",
"default" ], states: { require: {}, modify: {}, init: { _id: true, name: true,
banResetDate: true, creationDate: true, female: true, isAdmin: true, __v: true,
password: true, salt: true }, default: {} }, paths: { _id: "init", name: "init",
banResetDate: "init", creationDate: "init", female: "init", isAdmin:"init", __v:
"init", password: "init", salt: "init" } }, scope: null, wasPopulated: false,
populated: null, populate: null, _id: null, getters: {}, version: null, inserting:
null, removing: null, adhocPaths: null, validationError: null, saveError: null,
shardval: null, selected: null, strictMode: true } }

我无法在触发代码的简单变体中重现错误(该代码在 TCP 数据包的回调中运行)。

function test() {
var document = FindDocumentByCutoffId(Character, 1400622496);
console.log(document);
console.log(document.remove());
}
wait.launchFiber(test);
SetHandler 回调中的

character 与上面代码记录的对象是同一对象。

PacketHandler.SetHandler(0x0017, function (pSocket, pReader) {
var id = pReader.ReadUInt32();
var character = FindDocumentByCutoffId(Character, id, {
account: pSocket.account,
worldId: pSocket.state.worldId
});

if (!character) {
pSocket.Disconnect();
return;
}
wait.forMethod(character, 'remove');
});

global.FindDocumentByCutoffId = function (pSchema, pDocumentId, pFilterAdditions) {
var filter = pFilterAdditions || {};
pDocumentId = pDocumentId.toString(16);

// Get all rows
var rows = wait.forMethod(pSchema, 'find', '_id', filter);

for (var i = 0; i < rows.length; i++) {
if (String(rows[i]._id).indexOf(pDocumentId) == 0) {
return wait.forMethod(pSchema, 'findById', rows[i]._id);
}
}

return null;
};

编辑:等一下。为什么它会在错误中打印 Account 对象? O_o

最佳答案

如果您执行非法操作,例如尝试更新 FindOne 操作,则可能会出现此错误:

accounts.findOne({"user.email":options.user.email}, options, {upsert:false}, function(err, user) {
if (err) callback(err);
callback(null, 'updated thank you');
});

当正确的方法是:

时,将引发异常:
accounts.update({"user.email":options.user.email}, options, {upsert:false}, function(err, user) {
if (err) callback(err);
callback(null, 'updated thank you');
});

关于node.js - 蒙戈错误: Can't canonicalize query: BadValue >1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23771177/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com