Reputation: 1136
I want to check if a certain userid
is in the usedBy
child to ensure a user cannot use it twice, but I am having trouble trying to query the usedBy
child since it is entered by AutoID
I have something like this in Swift, but does not accomplish what I need, but do now know how to query it correctly:
promoCodes.child(code).child("usedBy").queryEqual(toValue: userid).observeSingleEvent(of: .value) { snapshot in }
Upvotes: 0
Views: 21
Reputation: 598951
Firebase Realtime Database queries always consist of two parts:
You're missing the first part in your query, which would be:
promoCodes.child(code).child("usedBy").queryOrdered(byChild:"userid").queryEqual(toValue: userid).
Upvotes: 1