Order of responses to MongoDB $in query? [duplicate]

Asked for this feature on JIRA:

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

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

vs.

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

Read the bug report for more info.

Update:

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

Leave a Comment