MongoDB Tricks: BSON Objects are Order-Prserving
Caught this one on the MongoDB mailinglist: BSON objects are preserving the order of the attributes, so the following behavior is expected:
db.test.save( {-id: {a:1, b:2}} )
db.test.find( {-id: {a:1, b:2}} ) // returns { "-id" : { "a" : 1, "b" : 2 } }
db.test.find( {-id: {b:2, a:1}} ) // nothing has been found
Original title and link: MongoDB Tricks: BSON Objects are Order-Prserving (NoSQL databases © myNoSQL)