Start a new topic

Unique objects


Imagine you are pressing a like button  and it unlikes ( deletes object) or likes ( creates objects).I have a problem when you spam the button really quickly and many times and pop the view, it might create 4-5 same instances of like from 1 user.

I have following algorithm.

Like pressed


//Like Button pressed

if (LikedAlready){ // unliking
if (objects_found > 0) { delete all }
{ // liking
if (objects_found == 0) { save like }
else if (objects_found == 1) { do nothing }
else if (objects_found > 1) {delete all and save one }

 This works perfectly if you press buttons then wait and close the view.

But it you close the view before all queries are done I will get  more than one created instance.

Is there any way to put constraints to on collection or a store query?

1 Comment

problem solved with front-end approach.