It is indeed tricky, especially for people new to MongoDB (and JSON) like myself. I was also trying to delete specific sub documents from MongoVUE but I couldn't figure out how. Finally I found the solution and I wanted to share it here in case other people run into the same problem.
I have this document (User):
{
"_id" : ObjectId("510d3e719d0d3627ec73abe4"),
"Name" : "John Doe",
"Country" : "USA",
"Highscores" : [{
"Score" : 15,
"DateStamp" : ISODate("2013-02-02T11:35:51.905Z")
}, {
"Score" : 19,
"DateStamp" : ISODate("2013-02-02T11:36:04.886Z")
}, {
"Score" : 40,
"DateStamp" : ISODate("2013-02-02T11:36:21.714Z")
}]
}
I want to delete scores above 20, i.e. only the last highscore and leave the list with two sub documents. I can find my document (the entire User document) by this query:
{ "Highscores.Score": { $gt: 20 } }
But if I open a Remove window in MongoVUE and enter the search query it will delete the entire User, including all highscores. I couldn't get $unset to delete the sub document and after some searching I found that this update JSON was the key:
{ $pull : { Highscores : { Score : { $gt: 20 } } } }
Hope it helps!