Query an array for an element
db.inventory.find( { tags: "red" } )
Check https://docs.mongodb.com/manual/tutorial/query-arrays/ for more.
Query in a nested JSON
## pymongo
rq3 = collection.find({'goal.stepGoal': {'$gt': 5000}})
Query the summation of an array
## pymongo
rq4 = collection.aggregate([
{
'$project':
{
'uid': '$uid',
'activityDurationTotal': { '$sum': '$activityDuration'}
}
}
])
Check https://docs.mongodb.com/manual/reference/operator/aggregation/sum/ for more.