I have a document in this structure
{
_id: 'playlistId',
list_of_songs: [
{
_id: 'songId',
song_title: 'Hello World',
song_artists: [
{
artist_name: 'Aaron',
}, {
artist_name: 'Ben',
}
]
}
]
}
I'm intending to replace the entire array list_of_songs.$.song_artists
for 'Hello World' in an update operation
newArrayOfArtists = [{...}, {...}, {...}]
Playlist.update({ _id: 'playlistId', }, {
$set: {
'list_of_songs.0.song_artists': newArrayOfArtists
}
}
but I'm hitting this error
cannot use the part (...) to traverse the element (...)
Am I doing something wrongly, or is this due to a limitation of MongoDB (see Updating nested arrays in mongoDB via mongo shell)? I'm at a total loss here, many thanks for helping.