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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -