I see this in Mongodb $push in nested array
What playlist.$.music represent.??
db.collection.update(
{ "_id": ID, "playlists._id": "58"},
{ "$push":
{"playlists.$.musics":
{
"name": "test name",
"duration": "4.00"
}
}
}
)
Since the $ operator is used for updating, quoting from the MongoDB documentation on $
for update,
The positional $ operator identifies an element in an array to update without explicitly specifying the position of the element in the array.
So in the code above, playlists.$.musics
part only states to update the property music of first document that matches the criteria on the first pipeline.
I hope this helps.