我是 mongodb 的新手。我正在尝试匹配集合数组中的用户名和密码。我的示例文档是
{
"_id" : ObjectId("51f20148a85e39af87510305"),
"group_name" : "sai",
"users" : [
{
"full_name" : "sumit",
"user_name" : "sumitdesh",
"password" : "mggg",
"status" : "Active"
},
{
"full_name" : "ad",
"user_name" : "asd",
"password" : "asdf",
"status" : "Active"
},
}
我正在尝试匹配用户在上述数组中输入的用户名和密码。如果用户名和密码与我们的数据匹配,则用户将登录。我的java代码是
BasicDBObject u = new BasicDBObject("users.user_name", uname);
BasicDBObject p = new BasicDBObject("users.password", password);
f=con.coll.find(u,p);