我的mongodb收藏中有新闻。
{
"_id" : ObjectId("593a97cdb17cc6535522d16a"),
"title" : "Title",
"text" : "Test",
"data" : "9.06.2017, 14:39:33",
"author" : "Admin",
"categoryList" : [
{
"_id" : null,
"text" : "category1"
},
{
"_id" : null,
"text" : "category2"
},
{
"_id" : null,
"text" : "category3"
}
]
}
每条新闻记录都有类别列表。我很想找到category1
categoryList
newsRepository.findByCategoryList("category1");
的所有新闻
variable "number_of_queues" {
default = 3
}
resource "aws_sqs_queue" "queue_name" {
count = "${var.number_of_queues}"
name = "queue_name_${count.index}"
// Other properties omitted
}
data "aws_iam_policy_document" "my_policy" {
count = "${var.number_of_queues}"
statement {
resources = [
"${aws_sqs_queue.queue_name[count.index].arn}",
]
// Other properties omitted
}
}
resource "aws_sqs_queue_policy" "queue_name_policy" {
count = "${var.number_of_queues}"
queue_url = "${aws_sqs_queue.queue_name[count.index].id}"
policy = "${data.aws_iam_policy_document.my_policy[count.index].json}"
}
但没有工作。
怎么做?
答案 0 :(得分:1)
使用您当前的存储库方法,生成的查询为
{ "categoryList" : "category1"}
您需要的是
{ "categoryList.text" : "category1"}
您可以通过两种方式创建查询。
使用存储库
findByCategoryListText(String category)
使用查询方法
@Query("{'categoryList.text': ?0}")
findByCategoryList(String category)