1

我有三个集合我如何创建一个模型,如果我想找到一个具有调节器 ID 的用户的 auto_mobile_reference_no:“ABA123”,我该怎么做?

//Company collection
{
    "company_id" : "NUV123",
    "company_name" : "ABC",

}

//Adjustor collection

{  
    "admin" : true,
    "claim_adjustor_id" : "ABA123",

    "company_id" : "NUV123",
    "adjustor_username" : "test",
    "adjustor_password" : "test"
},
{  
    "admin" : true,
    "claim_adjustor_id" : "XYQ324",

    "company_id" : "NUV123",
    "adjustor_username" : "test1",
    "adjustor_password" : "test22"
}

//Image collection

{  
    "claim_adjustor_id" : "ABA123",
    "automobile_reference_no" : "1LNHM83W13Y609413",

    "date_last_predicted" : "03/12/2019"
}
4

1 回答 1

0

MongoDB 并非旨在跨集合进行高效连接。您应该考虑将数据(基于访问模式)合并到单个集合中。

如果您的集合是未分片的,那么您可以使用聚合框架。您可以使用组合$match$lookup阶段来查询外部集合并将数据与另一个集合。从 4.0 版开始,$lookup不支持分片集合。因此,如果您的数据集很大,它可能对您不起作用。

你可以在这里阅读更多

于 2019-03-12T18:30:01.567 回答