I am executing a query like this on a MongoDB collection:
cursor = collection.find({"activityArray":{"$elemMatch":{"sport":0}}},{"activityArray.sport" : 1, "activityArray\|here is result object
.id":1, "endo" : 1}) |20166249
for result_object in cursor[0:1]: |here is result object
print "here is result object" |20166249 |here is result object
print result_object["endo"] |20166249
# print result_object["activityArray.sport"]
# print result_object["activityArray"]["sport"]
# print result_object["sport"]
Each of the commented out lines gives me a key error. How can I access those fields returned from a document within an array within a document resulting from a PyMongo query?