如何在Mongodb上删除文档


how to delete in the document on Mongodb

我有这个集合,我想删除"this my comment",如下所示。如何用mongodb完成?

"comments" : [ { "comment" : "this is my comment", "user" : "admin" } ] }

这是我的查询,但是,它不起作用:

db.article.remove( { "comment" : "this is my comment"} )

可以使用pull操作符删除注释。http://docs.mongodb.org/manual/reference/operator/update/pull/

db.article.update(   
{ },
{ "$pull": { "comments": { "comment" : "this is my comment" } } },
{ "multi": true }
)