node.js - MongoError: Can't canonicalize query: BadValue -
https://mongodb.github.io/node-mongodb-native/2.1/api/collection.html#findone
states max
option used number.
var result = yield mycol.findone({ lol: lol }, { max: 1 });
i error though:
mongoerror: can't canonicalize query: badvalue $max must bsonobj @ function.mongoerror.create (/home/karl/www/instantynode/src/node_modules/mongodb-core/lib/error.js:31:11) @ querycallback (/home/karl/www/instantynode/src/node_modules/mongodb-core/lib/cursor.js:266:34) @ callbacks.emit (/home/karl/www/instantynode/src/node_modules/mongodb-core/lib/topologies/server.js:95:3) @ null.messagehandler (/home/karl/www/instantynode/src/node_modules/mongodb-core/lib/topologies/server.js:249:23) @ socket.<anonymous> (/home/karl/www/instantynode/src/node_modules/mongodb-core/lib/connection/connection.js:265:22) @ emitone (events.js:77:13) @ socket.emit (events.js:169:7) @ readableaddchunk (_stream_readable.js:146:16) @ socket.readable.push (_stream_readable.js:110:10) @ tcp.onread (net.js:523:20)
edit: realized method depreciated , using find better.
max
amethod, not option, , takes bsondocument input:
var result = yield mycol.findone({ lol: lol }).max({field1:1});
Comments
Post a Comment