parse.com - Parse increment two fields at the same time. One field dependent on the other -
i have object in parse keep average score. object has 2 fields: "count" , "average". every time user posts new score, need update running average. example, if count=3 , average = 10, posting new score of 20 needs set count=4 , average = 12.5.
now average of multiple users. how block other users updating "count" field, while reading "count", using compute , update "average"?
thanks in advance. zak.
i found solution. it's not pretty, works.
i don't store average anymore. instead, store "count" , "runningscore". runningscore total of scores. then, while displaying in app, compute average using count , runningscore (instead of storing average). count , runningscore can incremented no problem.
Comments
Post a Comment