Does the $in operator preserves the order of the array?

https://docs.mongodb.com/manual/reference/operator/query/in/index.html

As outlined in this document:
https://docs.mongodb.com/manual/tutorial/model-referenced-one-to-many-relationships-between-documents/

As the references are stored in a array, it makes sense to preserve the order.

Hi @Adriano_Tirloni,

Welcome to MongoDB community

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.

Thanks
Pavel