gpt4 book ai didi

node.js - 蒙哥错误: Can't canonicalize query: BadValue

转载 作者:可可西里 更新时间:2023-11-01 09:50:35 24 4
gpt4 key购买 nike

https://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne

说明 max 选项将与数字一起使用。

var result =
yield myCol.findOne({
lol: lol
}, {
max: 1
});

虽然我得到了这个错误:

 MongoError: Can't canonicalize query: BadValue $max must be a BSONObj
at Function.MongoError.create (/home/karl/www/instantynode/src/node_modules/mongodb-core/lib/error.js:31:11)
at queryCallback (/home/karl/www/instantynode/src/node_modules/mongodb-core/lib/cursor.js:266:34)
at Callbacks.emit (/home/karl/www/instantynode/src/node_modules/mongodb-core/lib/topologies/server.js:95:3)
at null.messageHandler (/home/karl/www/instantynode/src/node_modules/mongodb-core/lib/topologies/server.js:249:23)
at Socket.<anonymous> (/home/karl/www/instantynode/src/node_modules/mongodb-core/lib/connection/connection.js:265:22)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at Socket.Readable.push (_stream_readable.js:110:10)
at TCP.onread (net.js:523:20)

编辑:刚刚意识到这种方法已过时,使用 find 更好。

最佳答案

max 是一个方法,不是一个选项,它需要一个 BsonDocument 作为输入:

var result =
yield myCol.findOne({
lol: lol
}).max({field1:1});

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

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