Is it possible to keep the original field order when migrating a relational database to MongoDB?

I am in the process of migrating tables with MongoDB Relational Migrator from a relational database (I have tried both MySQL and PostgreSQL as source) to MongoDB. The data records in the MongoDB documents are always stored in alphabetical order.

Is it possible to keep the original field order and place the embedded documents at the end?

Hi @VPO.Guru and welcome to the community forum!!

Ideally, MongoDB does not store the documents in the collection in alphabetic order. However, if the Relational Migrator stores the documents alphabetically, it should not be an issues while performing the query operations.

In your use case described above, if you are facing difficulty while storing or querying the data, could you please help us with the error message that you are seeing?


Hi @Aasawari,

This is actually not a big deal, but the migrated JSON is easier to read if the fields are sorted logically and not alphabetically. In a relational database table, the fields are usually arranged logically rather than alphabetically.