Look at the example: http://pastie.org/5901177
In that code I create 3 clients and push them into user.clients array. After that I added one more client on a top of user.clients array. So when I do
Client.where('_id').in(user.clients)
I'm getting clients in wrong order. Look at this please via console. Does anybody know what's problem in my code?
The order of the returned documents is not affected by the order of the array elements of the $in operator used to identify them in a find.
You always need to explicitly sort if you want a specific document order from a find.