1

How to retrieve all children except one which is equal with id value in Firebase Database?
For instance, in SQL we can do like this:

SELECT * FROM users WHERE id!=user_id
  • users
    • K4i0dvMU8sMd1AA1lSLwQraHujC3
    • lIWobPViMmZcFiSsOIpvdflcZe53
    • rubSXsacSSYGoh1VwbXtWiFEsWt2
    • uMFNR972cTdr8UfEXoiyIe3EMYb2

This is how the database looks like

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • It's difficult to answer to match your particular problem with so few information. What I CAN say is that you probably want Firebase's `Query`. You can find the doc [here](https://firebase.google.com/docs/reference/android/com/google/firebase/database/Query). Unfortunately, there is no "unequal" method. If it's only one node that is gonna be affected, maybe retrieving everything and ignoring that object is not so bad – Sunshinator Apr 12 '17 at 17:24
  • Please put your any code or put your firebase database image @Shukri – Anand Diamond Apr 12 '17 at 17:30

1 Answers1

0

You can simply do this client-side to filter one value

(psuedo-code)

for (DataSnapshot child : ref.getChildren()) {
    User user = child.getValue(User.class);
    if (!user.getId().equals(user_id)) { 
        list.add(value); 
}

You're showing the UUID that firebase generated, though, so I don't know how you expect to know that ahead of time to filter anything.

If there is some nested user_id key within those objects, or you can redo your database to store a known user id, then use that.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245