I need to update a field of one element from array sub document of a document.
MongoDB have the $ positional operator to do this. But in MongoDB C# driver version 2 it seems that there is no support for this operator.
How can I achieve this?
Documents:
{ "_id" : 1, "grades" : [ 80, 85, 90 ] }
{ "_id" : 2, "grades" : [ 88, 90, 92 ] }
{ "_id" : 3, "grades" : [ 85, 100, 90 ] }
Expected query:
db.students.update(
{ _id: 1, grades: 80 },
{ $set: { "grades.$" : 82 } }
)