且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

对 MongoDB $in 查询的响应顺序?

更新时间:2023-12-06 07:59:16

JIRA:

很快得到了很好的回应:使用 $or 而不是 $in

Quickly got a pretty good response: use $or instead of $in

c.find( { _id:{ $in:[ 1, 2, 0 ] } } ).toArray()

对比

c.find( { $or:[ { _id:1 }, { _id:2 }, { _id:0 } ] } ).toArray()

阅读错误报告了解更多信息.

Read the bug report for more info.

更新:

$or work-around hack 从 2.6.x 开始不再有效 - 这是实现的副作用,它具有 已更改.

The $or work-around hack no longer works starting with 2.6.x - it was a side effect of implementation which has changed.