0

I'm writing a simple app in which users can enroll for a specific course, but only when there is enough place. So a course would have a list of participants and a maximum participants number. The code that updates the participants list should do that only if the current participants list size is less than the max participants number. I'm going to disable the UI, if the list gets full an no more people can enroll, but still there will be some rare cases when it doesn't update fast enough and people would still click and enroll themselves. So I guess there should be some kind of a check on the database side? How can I achieve a behavior like this in Firebase?

adjuremods
  • 2,938
  • 2
  • 12
  • 17
dud3rino
  • 517
  • 4
  • 8
  • 1
    What have you tried so far? See [security rules](https://firebase.google.com/docs/database/security/). You're probably looking to add a `.validate` rule. – Kato Nov 30 '16 at 21:18
  • Can you show us some code ? – PedroAGSantos Nov 30 '16 at 21:26
  • @Kato, thanks for pointing me into that direction, looks like variation rules might be the thing. Here is a similar question, I think: http://stackoverflow.com/questions/22644202/limit-number-of-records-that-can-be-written-to-a-path-reference-other-paths-in. I'll investigate the subject. – dud3rino Nov 30 '16 at 23:08

0 Answers0