You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
what's your actual problem with Mongoengine using _cls in all queries? When querying from a subclass, e.g EventB.objects.first(), _cls is used to filter on that specific "EventB" class so removing it wouldn't make much sense as it would make it return another type of object... You can query the parent class if you don't want _cls
Activity
bagerard commentedon Apr 6, 2023
what's your actual problem with Mongoengine using
_clsin all queries? When querying from a subclass, e.gEventB.objects.first(),_clsis used to filter on that specific "EventB" class so removing it wouldn't make much sense as it would make it return another type of object... You can query the parent class if you don't want _clskietheros commentedon Apr 6, 2023
@bagerard
Query: List all events in a source_ids
BaseEvent.objects.filter(source_id__in=[1, 2 , 3], ...)Generate query:
('filter', {'source_id': {'$in': [1,2,3]}, '_cls': {'$in': ('BaseEvent', 'BaseEvent.SimpleEvent', 'BaseEvent.EventA', 'BaseEvent.SimpleEvent.EventB')}})Runtime: 0.9s
While I only need to filter by source_id
('filter', {'source_id': {'$in': [1,2,3]}}})Run time: 0.5s