According to https://docs.mongodb.com/manual/reference/bson-type-comparison-order/#objects, embedded objects/documents are compared, first, by field names, second, by field values.
Consider a collection:
and a query:
I thought this would return ONLY doc 3 (since `bab` and `bar` are less than `baz`), but it returns ALL three docs. Changing the query to
returns ONLY doc 3, as I hoped.
Is this an issue? Are range queries supported on whole embedded objects values? Do MinKey and MaxKey have some weird behavior in queries embedded documents?