3

I have some data that's structured like this:

users:
   0SWwfKinLNSTcNrfHROvG0gGIYm1: "Godkoala"
   1koVpFjqBoWrHqFEXtC0dkhjjOW2: "Ricky Ballby"
   2KGNwFZe3IP4ehf0RIcUPQHS6rr2: "TetrahedroN"
   2V1izMVUXgQTWPBXSS3V5A6HklF3: "Ponyta"

I want users to NOT be able to write if the new data's value matches any of the value's in the users section. In other words I want the values of this users section to be unique.

I know to check if a key already exists I can do something like:

".write":  "data.val() == null"

But I'm wondering if there's a way to check if a value doesn't exist instead.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Bender
  • 87
  • 2
  • 7
  • It is not possible to ensure a value is unique. The only way you can ensure uniqueness is to turn them into keys. See http://stackoverflow.com/questions/38442291/firebase-duplicate-username-and-custom-sign-in – Frank van Puffelen Aug 12 '16 at 14:25

0 Answers0