How to compare two Child values in Firebase

Asked

Viewed 97 times

0

I have two types of users: Vendedores and Usuarios. Applicants can display their data if the Ids are the same (already functional). Users should see Sellers' values if their child ("City") has the same value.

I tried to:

//Vendedores
      "Vendedores": {
      "$uid": {
        ".read": "auth.uid == $uid || (data.child(auth.uid).child('Cidade').val() === data.child($uid).child('Cidade').val())",
       ".write": "auth.uid == $uid"
      }

But it’s always true.

  • Could you translate your question ?

  • To have access to the Seller, the user needs to have in the key City, the same "City" / Variable, that the Seller has.

  • I would like to know how to do this. Since the rule I wrote is always true.

  • Your question is in English, you could translate it to improve the experience with other users.

  • 2

    I’m new, I didn’t know I would fall in the Brazilian forum.

  • I made some adjustments to your question!

Show 1 more comment

1 answer

0


I had forgotten to correctly reference the path. By the test console became functional, the application is still having access denied.

 "Vendedores": {
      "$uid": {
        ".read": "auth.uid == $uid || root.child('Usuarios').child(auth.uid).child('Cidade').val() == root.child('Vendedores').child($uid).child('Cidade').val()",
       ".write": "auth.uid == $uid"
      }

}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.