首页 > 解决方案 > Mongo获取多个集合查询

问题描述

我正在练习并且对 MongoDb 数据库查询非常陌生。我有三个集合数据。一个系列是客户,一个系列是客户的包,最后一个系列是客户的布。他们每个人都与id连接。我正在使用MongoDB 包进行连接和查询。我的目标是当客户的布料被出售时,它会从我想要获取客户信息的 bagId 中查找 bagId。.我真的不知道如何查询这个 MongoDB。

我的客户数据是这样的

_id:058585821193645242
accountNumber:"GI-325202"
address:"Calfornia"
city: "Calfornia"
email: "customer@gmail.com"
firstName:"John"
lastName:"doe"
name: "John doe"
phoneNumber: "0000-000"
customerId: 1200 // this id is connected with my bag collection

这是包系列

  bagId:119
  customerId:1200 // this my customer Id 

这是我的布系列

clothId: 123
bagId: 119 
status: sold. // this is my cloth status

clothId: 123
bagId: 119 
status: not sold. // this is my cloth status

标签: mongodbmongodb-query

解决方案



推荐阅读