IT虾米网

MongoDB嵌套查询使用聚合函数

txw1958 2023年07月21日 程序员 1075 0

我有一个集合“superpack”,其中包含嵌套对象。示例文档如下所示。

{ 
  "_id" : ObjectId("56038c8cca689261baca93eb"), 
  "name": "Test sub", 
  "packs": [ 
  { 
  "id": "55fbc7f6b0ce97a309b3cead", 
  "name": "Classic", 
  "packDispVal": "PACK", 
  "billingPts": [ 
    { 
      "id": "55fbc7f6b0ce97a309b3ceab", 
      "name": "Classic 1 month", 
      "expiryVal": 1, 
      "amount": 20, 
      "topUps": [ 
        { 
          "id": "55fbc7f6b0ce97a309b3cea9", 
          "name": "1 extra", 
          "amount": 8 
        }, 
        { 
          "id": "55fbc7f6b0ce97a309b3ceaa", 
          "name": "2 extra", 
          "amount": 12 
        } 
      ] 
    }, 
评论关闭
IT虾米网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!