I have a list with some mongodb queries in python, but I can't get data from some complicated queries that works in mongodb.
sql = [
[
{"$match": {
"status": {"$in" : ["BUILDING"]}
}
}
,{"$group": {
"_id": '$status', "count": {"$count": {}}
}
}
],
]
collection = client["send"]["sendEntity"]
mydoc = list(collection.find(myquery))
The error is as follows:
<class 'TypeError'>
traceback
Traceback (most recent call last):
File "getSql.py", line 14, in <module>
mydoc = list(collection.find(myquery))
File "/home/r/Desktop/table_csv/virtual/lib/python3.8/site-packages/pymongo/collection.py", line 1643, in find
return Cursor(self, *args, **kwargs)
File "/home/r/Desktop/table_csv/virtual/lib/python3.8/site-packages/pymongo/cursor.py", line 215, in __init__
validate_is_mapping("filter", spec)
File "/home/r/Desktop/table_csv/virtual/lib/python3.8/site-packages/pymongo/common.py", line 511, in validate_is_mapping
raise TypeError(
TypeError: filter must be an instance of dict, bson.son.SON, or any other type that inherits from collections.Mapping