MongoDB updating fields in nested array
How can I set "play" to "play photo" in the photos
array?
I only know its _id
.
"_id": ObjectId("4f41a5c7c32810e404000000"),
"albums": [
{
"_id": ObjectId("4f545d1bc328103812000000"),
"name": "album1" ,
"photos":[{
"_id": ObjectId("4f545d1bc328103812d00000"),
"name":"travel photo"
},{
"_id": ObjectId("4f545d1bc328103812c00000"),
"name":"play"
}]
},
{
"_id": ObjectId("4f545f56c328103c12000000"),
"name": "album2"
},
{
"_id": ObjectId("4f545f68c328103012000000"),
"name": "album3"
},
{
"_id": ObjectId("4f546642c328103c12000001"),
"name": "album4"
}]
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…