我有一个大收藏,现在被分成了两个收藏。现在,我想通过一个mongo查询从两个文档中检索文档。
到目前为止,我唯一想到的解决方案是分别在这两个集合上编写两个查询,然后在应用程序级别合并结果!
我想在db层本身上实现这一目标,因为合并两个集合后我拥有的文档数量超过了100万!
例如:
CollectionA: {field_1: "abc", field_2: "xyz", field_3: "abcxyz"},
{field_1: "def", field_2: "ghi", field_3: "defghi"}
CollectionB: {field_1: "qwe", field_2: "rty", field_3: "qwerty"}
Result: {field_1: "abc", field_2: "xyz", field_3: "abcxyz"},
{field_1: "def", field_2: "ghi", field_3: "defghi"},
{field_1: "qwe", field_2: "rty", field_3: "qwerty"}