Skip to content

Greater than (gte) query in MongoEngine for EmbeddedDocumentListField #1291

Description

@nilay-gpt

So this is how my models look like. Class A is having an EmbeddedDocumentListField of SlotTime

class SlotTime(EmbeddedDocument):
         # this is having minutes like 780 for 1pm.
         start_time = IntField(required=True)
         end_time = IntField(required=True)

class A(Document):
        name = StringField(primary_key=True)
        slot_hours = EmbeddedDocumentListField(SlotTime)

SlotTime has a list of objects with start and end time value.
[<SlotTime: SlotTime object>,<SlotTime: SlotTime object>]
and now I want to make a query that will return me the results that have start_time greater that to a given value. want a something similar to this query-
A.objects.get(name__exact='xyz').slot_hours.filter(start_time__gte=780)

tried this but this is returning all the value.
A.objects.filter(name__exact='xyz',slot_hours__start_time__gte=780)[0].slot_hours

Any idea, how to do this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions