@@ -201,6 +201,37 @@ Document Size Limit
201201Document Field Order
202202~~~~~~~~~~~~~~~~~~~~
203203
204+ Unlike JavaScript objects, the fields in a BSON document are ordered.
205+
206+ Field Order in Queries
207+ ``````````````````````
208+
209+ For queries, the field order behavior is as follows:
210+
211+ - When comparing documents, field ordering is significant. For
212+ example, when comparing documents with fields ``a`` and ``b`` in a
213+ query:
214+
215+ - ``{a: 1, b: 1}`` is equal to ``{a: 1, b: 1}``
216+
217+ - ``{a: 1, b: 1}`` is not equal to ``{b: 1, a: 1}``
218+
219+ - For efficient query execution, the query engine may reorder fields
220+ during query processing. Among other cases, reordering fields may
221+ occur when processing these projection operators:
222+ :pipeline:`$project`, :pipeline:`$addFields`, :pipeline:`$set`, and
223+ :pipeline:`$unset`.
224+
225+ - Field reordering may occur in intermediate results as well as the
226+ final results returned by a query.
227+
228+ - Because some operations may reorder fields, you should not rely on
229+ specific field ordering in the results returned by a query that
230+ uses the projection operators listed earlier.
231+
232+ Field Order in Write Operations
233+ ```````````````````````````````
234+
204235.. include:: /includes/fact-update-field-order.rst
205236 :start-after: order-of-document-fields
206237
0 commit comments