Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongodump and mongorestore changes order of documents

I am using mongodump command to dump mongodb data, but when I am restoring it using mongorestore it changes order of documents (order in which documents was inserted), What might be the issue? Is there any way by which I can preserve insertion order?

like image 269
Rushi Soni Avatar asked Mar 11 '23 03:03

Rushi Soni


1 Answers

You can use "maintainInsertionOrder" to preserve the insertion order. The default is False.

--maintainInsertionOrder

Default: False

If specified, mongorestore inserts the documents in the order of their appearance in the input source, otherwise mongorestore may perform the insertions in an arbitrary order.

like image 186
notionquest Avatar answered Mar 23 '23 22:03

notionquest