I have been doing experiments on MongoDB. Collection are as follows(sample).
Project this, in this class of 95th DeleteAlbum line have the function of.
{
"_id": {
"$oid": "50e34afce4b0bc114fea2a7e"
},
"Ad": "Tarkan", //Artist
"Albums": [
{
"_id": {
"$oid": "50e34afce4b0bc114fea2a4e"
},
"Isim": "DUDU", //Name
"Yil": 2005, //Year
"Resim": "http://www.gercekpop.com/wp-content/uploads/2003/12/tarkan-dudu.jpg" //Image
},
{
"_id": {
"$oid": "50e34afce4b0bc114fea2a3e"
},
"Isim": "Kuzu Kuzu",
"Yil": 2008,
"Resim": "http://o.scdn.co/300/bf6423177c32224f25dc742f3ffe5450e441d68d"
}
]
}
line 75th Add method in CreateAlbum function are working.
Artist.Albums.Add(Album)
Return Collection.Save(Artist, SafeMode.True).Ok
but Remove method in DeleteAlbum not work.
Artist.Albums.Remove(album)
Return Collection.Save(sanatci, SafeMode.True).Ok
What should be the method to delete the embedded document? Thank you for your help.
updatewith the$pulloperator to remove an element from an array field.