I am using below query to get data from the collection in mongodb
db.testcoll.aggregate([
{ $unwind :'$data'},
{ $match : {'type': 'data1', "my_id" : "44ef", 'data.time': { $gte : "2018-07-07 00:00:30" , $lte : "2018-07-08 00:57:30"} }},
{ $project : { _id:0, my_id: '$my_id', time : '$data.time', value : '$data.value'} }
])
Running the above query in MongoDb, I get appropriate results. Now I am writing a small python script where I need to run the same query.
query = ([
{ '$unwind' :'$data'},
{ '$match' : {'type': 'data1', "my_id" : "44ef", 'data.time': { '$gte' : "2018-07-07 00:00:30" , '$lte' : "2018-07-08 00:57:30"} }},
{ '$project' : { '_id':0, 'my_id': '$my_id', 'time' : '$data.time', 'value' : '$data.value'} }
])
document = testcoll.find(query)
for i in document:
print(i)
It shows document values as None in debugger and thus throws error:
TypeError: 'NoneType' object is not iterable
How can I run the query in python. Thanks