How do you create a precise number counter?

I created a voting app, to be counting number of voters, but when 2 users click at the same time, it will count them as 1 instead to count 1 by 1, what can I do

The answer depends on the shared data base.

The general way around the shared update problem is to turn updates into list inserts, like this database structure:

  • Supreme Commander votes
    • candidates
      • ABG
        • voters
          • ABG (yes, I voted for myself)
          • Dckings
      • Dckings
        • voters
          • Dckings

There's no privacy here, and it is up to the app to make sure no one votes for the same office twice.

2 Likes