如何在MongoDB中汇总来自多个集合的查询结果?

时间:2018-10-05 15:11:31

标签: java mongodb spring-boot

我有一个springboot项目,该项目具有mongoDB作为数据库。我的MongoDB中有多个集合。每个类别都有自己的类似于以下内容的集合。

Category_A
{ _id: 101, firstName: "Emma", surname: "Jackson", city: "Manchester"}
{ _id: 102, firstName: "Jane", surname: "Reynolds", city: "York"}

Category_B
{ _id: 201, firstName: "Julia", surname: "Jacob", city: "York"}
{ _id: 202, firstName: "Eric", surname: "Philips", city: "Bristol"}

Category_C
{ _id: 301, firstName: "Annie", surname: "Jones", city: "York"}
{ _id: 302, firstName: "Ryan", surname: "Lewis", city: "Bristol"}

我必须查询所有集合以找到来自York的人,然后将它们放在视图中以执行限制,并跳过该视图以支持分页。

我不确定如何将每个集合的查询结果合并到一个视图中。限制和跳过适用于视图吗?

0 个答案:

没有答案