0

I use this future.

  future: firebase.FirebaseDatabase.instance
      .reference()
      .child("group")
      .orderByChild('userId')
      .onValue
      .contains(userID),

ScreenShot of Realtime database.

enter image description here

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Deval Joshi
  • 163
  • 10
  • 1
    Firebase Realtime Database queries function on a flat list of *direct* child nodes under the path that you query (so `group` in your case). Queries can only order/filter on values that are at a fixed path under each child node. So in your data structure you can filter all groups on things like `castDesc` or `castName`. You can't however filter all groups on all users. See the questions I linked, and https://stackoverflow.com/questions/70793541/firebase-realtime-database-reach-nested-child/70793948#70793948 (which is very similar and I answered yesterday). – Frank van Puffelen Jan 21 '22 at 15:43

1 Answers1

-1

arrayOfUserIds.contains(userId)

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
takudzw_M
  • 186
  • 1
  • 5
  • 2
    Remember that Stack Overflow isn't just intended to solve the immediate problem, but also to help future readers find solutions to similar problems, which requires understanding the underlying code. This is especially important for members of our community who are beginners, and not familiar with the syntax. Given that, **can you [edit] your answer to include an explanation of what you're doing** and why you believe it is the best approach? – Jeremy Caney Jan 22 '22 at 09:30