以下の構造の(CustomerInformation) というmongoコレクションのドキュメントを持っています。春データ-Mongo DBクエリ埋め込み配列
{ "_id" : ObjectId("58f5e68c8205281d68bbb290"),
"_class" : "com.test.dataservices.entity.CustomerInformation",
"organizationInformation" : {
"_id" : "123",
"companyName" : "Test1",
"ibanNumber" : "12345e",
"address" : "estates",
"contractInformation" : {
"duration" : NumberInt(0),
"contractType" : "Gold",
"totalUsers" : NumberInt(0)
},
"users" : [
{
"firstName" : "testuser1",
"emailAddress" : "[email protected]",
"password" : "[email protected]",
"userAccessType" : "admin"
},
{
"firstName" : "testuser2",
"emailAddress" : "[email protected]",
"password" : "[email protected]",
"userAccessType" : "user"
}
]
}
}
これで、emailAddressとPasswordが一致するユーザー情報のみを取得します。私は次のように努力しています。
Criteria elementMatchCriteria = Criteria.where("organizationInformation.users").
elemMatch(Criteria.where("emailaddress").is("[email protected]").and("password").is([email protected]));
BasicQuery query = new BasicQuery(elementMatchCriteria.getCriteriaObject());
CustomerInformation customer =mongoOperations.findOne(query, CustomerInformation.class);
私は、すべてのユーザーの配列と完全な文書を取得しています、私は唯一の一致するユーザー情報EMAILADDRESSとパスワードを取得したいです。 クエリまたはデータモデルで何が間違っていますか? 提案がありますか?ありがとうございました!
ありがとうございます。その仕事.. –