specifying $push location in collection using Pymongo
问题 I'm wondering how to use $push in a collection where I have to specify which document I want to add information to. Please consider the following example: student1 = { 'name': 'Adam', 'year': 'sophomore', 'age': 20, 'class':[ { 'className': 'cse131', 'time': '2:30', 'finalGrade': 'A' }, { 'className': 'cse240', 'time': '9:30', 'finalGrade': 'B' } ] } If I wanted to update only the first document in the 'class' collection (the cse131 in 'class'), how would I use $push to do this? For example,