When i run this code ,i get an error 'CommandCursor' object is not subscriptable pymongo version = 3.3.0
try:
myresults = students.aggregate([{"$unwind":"$scores"},{"$match":{"scores.type":"homework"}},{"$group":{"_id":"$_id","minitem":{"$min":"$scores.score"}}}],useCursor=False)
for result in myresults['result']:
scores.update({"_id":result["_id"]},{"$pull":{"scores":{"score": result["minitem"]}}})
except Exception as e:
raise