Simple question, do arrays keep their order when stored in MongoDB?
MongoDB only gurantee order of documents based on a sort operation. Therefore, even if some queries will return the order you need it won't be guaranteed for every query.
Documents are stored in natural order The documents are stored in descending order based on date. So the collection has 20140731 as the first document. Unless you are using a capped collection, there is no guarantee for the ordering of documents on disk (also referred to as natural order).
yep MongoDB keeps the order of the array.. just like Javascript engines..
Yes, in fact from a quick google search on the subject, it seems that it's rather difficult to re-order them: http://groups.google.com/group/mongodb-user/browse_thread/thread/1df1654889e664c1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With