这是我的 mongo 文档:
{
"_id" : ObjectId("51f22f6784aefaa97d7e533e"),
"group_name" : "demo",
"privileges" : [
"User Group",
"Profile Images",
"Advertisement"
],
"users" : [
{
"full_name" : "aap",
"password" : "as",
"status" : "Active",
"user_name" : "as"
},
{
"full_name" : "b",
"user_name" : "b",
"password" : "b",
"status" : "Active"
},
{
"full_name" : "prashant",
"user_name" : "pt123",
"status" : "Active"
}
]
}
我想找到所有具有 "group_name":"demo" 的记录删除具有 "user_name":"pt123" 形式的用户数组的特定记录。我努力了
db.users.update({"group_name":"demo"}, {$pull:{"users.user_name":"pt123"}})
但显示没有效果。我缺哪里?请帮助我的java代码是
BasicDBObject del = new BasicDBObject("group_name", z);
del.put("users.user_name", x);
BasicDBObject delquery=new BasicDBObject("$match",del);
con.remove(delquery);