【发布时间】:2011-06-05 00:17:18
【问题描述】:
我在 MongoDB 中有收藏:
{ "_id" : ObjectId("4d2407265ff08824e3000001"), "subida" : 3.95 }
{ "_id" : ObjectId("4d2551b4ae9fa739640df821"), "subida" : 6.03 }
{ "_id" : ObjectId("4d255b115ff08821c2000001"), "subida" : 5.53 }
{ "_id" : ObjectId("4d25e8d55ff08814f8000001"), "subida" : 1.96 }
如何对所有文档中的键值求和,例如 "subida"?有了上述文件,我应该会收到以下内容:
{ "subida" : 17.47 }
【问题讨论】: