I have a small app where i record votes and reorder a list based on those votes. The app has users and each user can only vote once. For every record, when a user votes, i save the user id.
var obj = {};
obj[$scope.user.id] = {
avatar: $scope.user.avatar,
name : $scope.user.name
};
myDataRef.child("sessions/"+sessionId+"/list/"+key+"/votes")
.update(obj, function(error){}
The update() protects me, and does not allow repeated ids. With this i know that i have as many unique votes as voters. So, i want a field called 'score' that would automatically count the users and set the 'score' field with that count. How can i achieve this?
Tks