For a collection nameed 'duplicate', we can execute db.duplicate.find( { $where: "this.all_dups.length > 0" } ); but what would be the Python version of this query? I tried using
db.duplicate.find( { "$where": {"$gt":{"all_dups.length"} > 0] }} )
but it is showing me error for obvious reasons.
I also tried
db.duplicate.find( { "all_dups" : { "$size": { "$gt" : 0 }}})
I can do it in Python like:
for a in db.duplicate.find():
if 'all_dups' in a and len(a['all_dups'])>0:
print(a)
How can I achieve in PyMongo? I think there $exists, $where, $gt and $size will be used but I don't exactly know how.