python - PyMongo: Access fields returned from document within array resulting from find() query -


i executing query on mongodb collection:

 cursor = collection.find({"activityarray":{"$elemmatch":{"sport":0}}},{"activityarray.sport" : 1, "activityarray\|here result object .id":1, "endo" : 1})                                                                                                 |20166249     result_object in cursor[0:1]:                                                                                |here result object         print "here result object"                                                                                |20166249                                                            |here result object         print result_object["endo"]                                                                                  |20166249 #        print result_object["activityarray.sport"]    #        print result_object["activityarray"]["sport"]    #        print result_object["sport"]    

each of commented out lines gives me key error. how can access fields returned document within array within document resulting pymongo query?

since activityarray array, need have loop on list follows:

cursor = collection.find({"activityarray": {"$elemmatch": {"sport":0 }}},{"activityarray.sport" : 1, "activityarray.id":1, "endo" : 1})   result_object in cursor[0:1]:     print result_object["endo"])     activity in result_object["activityarray"]:         print activity["sport"] 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -