我的mongodb中有以下文档。
{
"_id" : "840e922e-05e0-4e4d-b574-303a72425bdd",
"_class" : "com.document.domain.Doc",
"type" : "User",
"name" : "steven",
"index" : 0,
"data" : "This is sample user",
"properties" : {
"displayName" : "steven",
"lastName" : "smith"
},
"tags" : [
"tag1",
"tag2"
],
"categories" : [
"category1",
"category2"
]
}
现在我想通过从json上面传递任何随机属性来检索文档。
Example: If I pass "type" as a key and "User" as value
If I pass "name" as a key and "steven" as value
像这个键可以是来自JSON的任何随机属性,值将是它的关联值,那么它应该返回给我那个文档。
我正在尝试查询:
@Query("{'property':?0,'property':?1}")
List<Doc> findByKeyAndValue(String key, String value);
但没有运气。
提前致谢。