Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/guide/querying.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,28 @@ syntax::
# been written by a user whose 'country' field is set to 'uk'
uk_pages = Page.objects(author__country='uk')

.. warning::

Be aware that MongoDB considers field order when matching an embedded
document. As a result, querying a :class:`~mongoengine.fields.DictField` or
:class:`~mongoengine.fields.MapField` against a complete dictionary only
matches when its keys are in the same order as the stored document. The same
applies when querying an :class:`~mongoengine.fields.EmbeddedDocumentField`
with an embedded document instance. For example, this query may not match
when the stored keys are in the opposite order::

SurveyResponse.objects(
answers={"question_2": "no", "question_1": "yes"},
)

Query individual dictionary keys to match their values regardless of
order::

SurveyResponse.objects(
answers__question_1="yes",
answers__question_2="no",
)

.. note::

(version **0.9.1+**) if your field name is like mongodb operator name (for example
Expand Down