0

My Firebase Structure

I am trying to query a firebase structured data in which I want to find out if particular nested node contains a value. The image attached is my structure. Please refer the figure.

Now my question is

I want to check if the tag attribute which is the child confession node has the value BE_CS_B_boy, but I don't know the parent key of the confession node (ie the Firebase generated UID)*. So how can I query it?

How should I traverse to get to the tag node to query it in Firebase. Because to go to the tag node I need to go through confession node and to go through confession node I need to mention the parent key (in this case it is the Firebase generated UID)

Note: My root node name is users as shown in the image attached. Please refer the figure.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Nishat Sayyed
  • 151
  • 2
  • 10
  • It looks like you're trying to query across two levels, which is not possible in the Firebase Realtime Database's query model. See https://stackoverflow.com/questions/27207059/firebase-query-double-nested – Frank van Puffelen Oct 08 '17 at 18:15

1 Answers1

0

It's not possible in Firebase Realtime Database.

The alternative (and Firebase Realtime Database way of thinking) is to create another root level node with the info you need to retrieve, for example:

vconfess
  - confessions_in_tags
    - tag_id
      - confession_id_1
      - confession_id_2

And, by doing so, you have to keep your denormalised data synchronised.

hecht
  • 292
  • 2
  • 6