如何使用来自另一个列表的 findById 从 MongoDB 检索特定的元素列表 =>主列表中的子列表?
如何检索此列表:
[
{
"id": "1",
"title": "Jordanian Mansaf",
"description": "content: blah blah blah, method: blah blah blah",
"imagePath": "Mansaf imagePath",
"created": "2022-03-12T04:42:39.818+00:00"
},
{
"id": "2",
"title": "Jordanian Maklobah",
"description": "content: blah blah blah, method: blah blah blah",
"imagePath": "Maklobah imagePath",
"created": "2022-03-12T04:43:10.869+00:00"
},
{
"id": "3",
"title": "Suadi Kabsah",
"description": "content: blah blah blah, method: blah blah blah",
"imagePath": "Kabsah imagePath",
"created": "2022-03-12T04:43:36.470+00:00"
},
{
"id": "4",
"title": "Briani",
"description": "content: blah blah blah, method: blah blah blah",
"imagePath": "Briani imagePath",
"created": "2022-03-12T04:44:03.227+00:00"
},
{
"id": "5",
"title": "Zarb",
"description": "Contnent: blah blah blah, Method: blah blah blah",
"imagePath": "Zarb_imagePath",
"created": "2022-03-12T11:43:26.330+00:00"
}
]
传递此列表[id]
时:
[
{
"id": "1",
"title": "Cat1",
"imagePath": "Cat1_imagePath",
"created": "2022-03-12T04:42:39.818+00:00"
},
{
"id": "2",
"title": "Cat2",
"imagePath": "Cat2_imagePath",
"created": "2022-03-12T04:43:10.869+00:00"
},
{
"id": "3",
"title": "Cat3",
"imagePath": "Cat3_imagePath",
"created": "2022-03-12T04:43:36.470+00:00"
},
{
"id": "4",
"title": "Cat4",
"imagePath": "Cat4 imagePath",
"created": "2022-03-12T04:44:03.227+00:00"
},
{
"id": "5",
"title": "Food Cat5",
"imagePath": "Cat5_imagePath",
"created": "2022-03-12T11:43:26.330+00:00"
}
]
How To Retrieve this list:
[
{
"id": "1",
"title": "Jordanian Mansaf",
"description": "content: blah blah blah, method: blah blah blah",
"imagePath": "Mansaf imagePath",
"created": "2022-03-12T04:42:39.818+00:00"
},
{
"id": "2",
"title": "Jordanian Maklobah",
"description": "content: blah blah blah, method: blah blah blah",
"imagePath": "Maklobah imagePath",
"created": "2022-03-12T04:43:10.869+00:00"
},
{
"id": "3",
"title": "Suadi Kabsah",
"description": "content: blah blah blah, method: blah blah blah",
"imagePath": "Kabsah imagePath",
"created": "2022-03-12T04:43:36.470+00:00"
},
{
"id": "4",
"title": "Briani",
"description": "content: blah blah blah, method: blah blah blah",
"imagePath": "Briani imagePath",
"created": "2022-03-12T04:44:03.227+00:00"
},
{
"id": "5",
"title": "Zarb",
"description": "Contnent: blah blah blah, Method: blah blah blah",
"imagePath": "Zarb_imagePath",
"created": "2022-03-12T11:43:26.330+00:00"
}
]
When passing this list [id]
:
[
{
"id": "1",
"title": "Cat1",
"imagePath": "Cat1_imagePath",
"created": "2022-03-12T04:42:39.818+00:00"
},
{
"id": "2",
"title": "Cat2",
"imagePath": "Cat2_imagePath",
"created": "2022-03-12T04:43:10.869+00:00"
},
{
"id": "3",
"title": "Cat3",
"imagePath": "Cat3_imagePath",
"created": "2022-03-12T04:43:36.470+00:00"
},
{
"id": "4",
"title": "Cat4",
"imagePath": "Cat4 imagePath",
"created": "2022-03-12T04:44:03.227+00:00"
},
{
"id": "5",
"title": "Food Cat5",
"imagePath": "Cat5_imagePath",
"created": "2022-03-12T11:43:26.330+00:00"
}
]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚找到了我的问题的答案,如下所示:
在 mongo 存储库中只需声明一个自定义查找方法:
然后将其用作普通查找方法 => [查询]在您的业务逻辑层和控制器层。
I just figured out an answer for my question and it's as follows:
In the mongo repository just declare a custom find method:
Then use it as a normal find method => [query] in your business logic layer and controller layer.