File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,6 +39,28 @@ syntax::
3939 # been written by a user whose 'country' field is set to 'uk'
4040 uk_pages = Page.objects(author__country='uk')
4141
42+ .. warning ::
43+
44+ Be aware that MongoDB considers field order when matching an embedded
45+ document. As a result, querying a :class: `~mongoengine.fields.DictField ` or
46+ :class: `~mongoengine.fields.MapField ` against a complete dictionary only
47+ matches when its keys are in the same order as the stored document. The same
48+ applies when querying an :class: `~mongoengine.fields.EmbeddedDocumentField `
49+ with an embedded document instance. For example, this query may not match
50+ when the stored keys are in the opposite order::
51+
52+ SurveyResponse.objects(
53+ answers={"question_2": "no", "question_1": "yes"},
54+ )
55+
56+ Query individual dictionary keys to match their values regardless of
57+ order::
58+
59+ SurveyResponse.objects(
60+ answers__question_1="yes",
61+ answers__question_2="no",
62+ )
63+
4264.. note ::
4365
4466 (version **0.9.1+ **) if your field name is like mongodb operator name (for example
You can’t perform that action at this time.
0 commit comments