Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
Creating increment limit

Ok so I am making a like/dislike system for my website and I got it to work. The only problem is, is that a user can like something more than once, how do I stop this? heres my function

    function thumbup(uid, s) {
        const prevthumbs = s.thumbs

            firebase.db.collection('users').doc(uid).update({
                thumbs: prevthumbs + 1
            })
            
    }

How can I limit the increment to only one?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

To limit how often the user can do something, use their UID as the key for the operation.

For example, if you don't have too many users, you can have a field likedBy in the document which is an array of the UIDs of the users who liked this user.

It's a bit unclear how to exactly implement it in your code for me, as you're already writing to a doc(uid), where usually the user is liking a post or something like that.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!