how do I check if an ListField() attribute of a Mongo Class is not set or empty?
Thanks!
how do I check if an ListField() attribute of a Mongo Class is not set or empty?
Thanks!
If you were looking for the reverse question (check if a list contains at least an element which implies that it also exists), here is how you can do it using a query dict for a change:
query = {}
query['tags__exists'] = True
query['tags__not__size'] = 0
for post in Post.objects(**query):
print(post)
As per the MongoEngine documentation, the not operator can be used to negate a standard check as long as it precedes the query operator.