以下是"用户"下特定用户的子节点的firebase数据库。节点:
"L1Bczun2d5UTZC8g2LXchLJVXsh1" : {
"email" : "orabbz@yahoo.com",
"fullname" : "orabueze yea",
"teamname" : "orabbz team",
"total" : 0,
"userName" : "orabbz@yahoo.com",
"week1" : 0,
"week10" : 0,
"week11" : 0,
"week12" : 0,
"week2" : 0,
"week3" : 17,
"week4" : 0,
"week5" : 20,
"week6" : 0,
"week7" : 0,
"week8" : 0,
"week9" : 10
},
有没有办法将Weeks 1
的所有值加到week 12
并在total
键中得到总和?
我正在考虑将第1周 - 第12周的所有值带入角度js范围,然后将值相加,然后将总数返回到firebase数据库键total
。但这听起来太长了。是否有更短的解决方案?
答案 0 :(得分:0)
据我所知,Firebase DB没有像SQL中那样拥有任何数据库功能。因此,您所拥有的选项是获取数据并按照您的说法在Angular中进行计算。或者在将周数添加到用户时(写入数据库时)更新计数器。然后稍后再阅读计数器