云开发数据库 对象数组的某个属性求和?
数据库数据
{ "_id": 1, "name":"Tom", "list": [{"course":"eglish", "score":60},{"course":"math", "score":70} ] }
{ "_id": 2, "name":"Kat", "list": [{"course":"eglish", "score":100},{"course":"math", "score":70} ] }
要求输出数据结果
{ "_id": 1, "name":"Tom", "total":130, "list": [{"course":"eglish", "score":60},{"course":"math", "score":70} ] }
{ "_id": 2, "name":"Kat", "total":170, "list": [{"course":"eglish", "score":100},{"course":"math", "score":70} ] }
怎么数组中对象的某个属性求和? reduce可以吗?