【发布时间】:2019-12-06 14:37:52
【问题描述】:
下面是mongodb文档是这样的和这些嵌套数组字段选择:
对象:
{
"_id": {
"$oid": "5de775b53ec85e73da2b6d8a"
},
"vpg_id": 2,
"year": 2019,
"am_data": {
"822": {
"am_name": "Unmanaged ",
"no_of_mnths": 12,
"total_invoice": 14476.15,
"total_bv_invoice": 1840,
"opp_won_onetime_amt": 0,
"one_time_quota": 0,
"recurring_quota": 200,
"opp_won_rec_amt": 0,
"avg_total_invoice": 1206.3458333333333,
"avg_total_bv_invoice": 153.33333333333334,
"avg_opp_won_onetime_amt": 0,
"avg_one_time_quota": 0,
"avg_opp_won_rec_amt": 0,
"avg_recurring_quota": 16.666666666666668
},
"2155": {
"am_name": "Daniel Schiralli",
"no_of_mnths": 12,
"total_invoice": 396814.66000000003,
"total_bv_invoice": 577693.3200000001,
"opp_won_onetime_amt": 4792.5,
"one_time_quota": 14400,
"recurring_quota": 4800,
"opp_won_rec_amt": 345,
"avg_total_invoice": 33067.888333333336,
"avg_total_bv_invoice": 48141.11000000001,
"avg_opp_won_onetime_amt": 399.375,
"avg_one_time_quota": 1200,
"avg_opp_won_rec_amt": 28.75,
"avg_recurring_quota": 400
}
}
}
我只想从所有 am_data 数组中选择 no_of_mnths 和 am_name。
钥匙
822
和
2155 是动态的。
它会改变,所以我不能直接在查询中给出它。我如何才能获得这些数据。不想
有什么帮助吗?
【问题讨论】: