I have this on my mongo database :
{
"_id" : ObjectId("585a60b45ba19c3eb2016a16"),
"userid" : ObjectId("585a60715ba19c3eb2016a14"),
"apps" : [
{
"name" : "Apptest",
"packagename" : "com.test.ezfez",
"iconurl" : "an_url",
"visited" : 0,
"category" : "category",
"_id" : ObjectId("585a61405ba19c3eb2016a17")
},
{
"name" : "test",
"packagename" : "test.packagename",
"iconurl" : "url",
"visited" : 0,
"category" : "",
"_id" : ObjectId("588755025ba19c6f870282d7")
}, ...
I want to remove on element from this array. I'm using golang and mgo.v2 driver and here is my code :
selector := bson.M{"userid": bson.ObjectIdHex("585a60715ba19c3eb2016a14")}
update := bson.M{"$pull": bson.M{"apps": bson.ObjectIdHex("585a61405ba19c3eb2016a17")}}
if err := uc.session.DB("API").C("aioapps").Update(selector, update); err != nil {
fmt.Println(err)
SendError(w, "Remove", "Error on delete app")
} else {
SendSuccess(w, "Remove", "Success")
}
It goes on Success but does not delete the item when I check on mongodb. Can soemeone tell me what I'm doing wrong ? Thank you