Finally I found the error,just I forgot a zero...( array)
db.Series.find({"curations.0.measurements._id":new ObjectId("52fdbbb470c68c3c14d90700")},
{ $set: {
"curations.0.measurements.$.Vals.4": "new_value" <=In this line
}
});
Вопрос
I need to update a nth element in a sub nested document:I have this structure:
{
"_id" : ObjectId("52fdbbb470c68c3c14d60700"),
"curations" : [{
"measurements" :
[
{
"_id" : ObjectId("52fdbbb470c68c3c14d80700"),
"name" : "GSM15729",
"Vals" : ["N/A", "bronchus, lung", "bronchial epithelial cell", "N/A", "N/A", "N/A", "non-smoker", "GPL96"]
},
{
"_id" : ObjectId("52fdbbb470c68c3c14d90700"),
"name" : "GSM104072",
"Vals" : ["N/A", "bronchus, lung", "bronchial epithelial cell", "N/A", "N/A", "N/A", "current smoker", "GPL96"]
}
]
}]
}
And I want to update for example the 4th "N/A"(5th position) in the last sub array "Vals"
I tried with the command line this code but it seems not to be working
db.Series.find({"curations.measurements._id":new ObjectId("52fdbbb470c68c3c14d90700")},
{ $set: {
"curations.measurements.$.Vals.4": "new_value"
}
});
Thanks for your help!!!
Решение
Finally I found the error,just I forgot a zero...( array)
db.Series.find({"curations.0.measurements._id":new ObjectId("52fdbbb470c68c3c14d90700")},
{ $set: {
"curations.0.measurements.$.Vals.4": "new_value" <=In this line
}
});