Hi Couchbase community
I am trying to implement a voting system in Android where users can vote for the images they like. Unfortunately I have no idea how I would go about handling concurrent users voting at the same time. Based on my experience once documents are synced with the server the latest update will overwrite the old ones. In my case I want to add up the votes given by my user.
At the moment, I am thinking of simply updating the field that contains the data i.e. when a user votes, vote field will have its content incremented by 1 but what if another user makes his vote I’m thinking he may increment the old data and not the latest one.
I have also thought about storing the names of the images that a user has voted for in a document but it sounds like adding up the votes for each image will burn a lot of mobile resources as I have to map the image name and count it via reduce to get the total votes. Correct me if im wrong but, If I have 1000 images then I would have to perform MapReduce a thousand times which I believe will burn a lot of mobile device’s CPU.
Has anyone stumbled upon this and figured a working solution?
Thanks, sorry for being vague