I have a map field that I want to query by. Something like:
class User(mongoengine.Document):
email = mongoengine.EmailField(required=False, unique=False)
username = mongoengine.StringField(max_length=30, min_length=6, required=True, unique=True)
password = mongoengine.StringField(max_length=500, min_length=6, required=True)
profiles = mongoengine.MapField(mongoengine.EmbeddedDocumentField(DeviceProfile))
So in the field, profiles, I store the objects like so: device_id: DeviceProfile object.
I tried: User.objects(profiles__device_id=device_id)
to no avail. How do I query so that I only return User objects that have a specific key in the profiles field? Basically, I want to query for User documents that contain a certain DeviceProfile object based on its device ID.