You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MongoDB按teamExternalId分组调整结果格式需求

MongoDB查询结果按teamExternalId分组

聚合查询命令

使用MongoDB的$group聚合操作可实现按teamExternalId分组,并将对应文档存入insight数组:

db.collection.aggregate([
  {
    $group: {
      _id: "$teamExternalId",
      insight: { $push: "$$ROOT" }
    }
  },
  {
    $project: {
      _id: 0,
      teamExternalId: "$_id",
      insight: 1
    }
  }
])

分组后结果

执行上述聚合命令后,将得到如下格式的结果:

{
  "teamExternalId": "b663fa97-22fa-44b9-b845-22a57d408550",
  "insight": [
    {
      "_id": "89787517-0085-3a0a-7232-1105457d6075",
      "totalStoriesPlanned": 2,
      "storiesWithDependencies": 0,
      "plannedVelocity": null,
      "actualVelocity": 0,
      "businessValue": 0,
      "sprintType": "Dev",
      "storyData": [],
      "teamExternalId": "b663fa97-22fa-44b9-b845-22a57d408550"
    },
    {
      "_id": "12347517-0085-3a0a-7232-1105457d6075",
      "totalStoriesPlanned": 2,
      "storiesWithDependencies": 0,
      "plannedVelocity": null,
      "actualVelocity": 0,
      "businessValue": 0,
      "sprintType": "Dev",
      "storyData": [],
      "teamExternalId": "b663fa97-22fa-44b9-b845-22a57d408550"
    }
  ]
}

内容的提问来源于stack exchange,提问作者Tasneem Desai

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 22:35:20