Skip to content Skip to sidebar Skip to footer

Firebase Retrieving All Children Except One

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

Solution 1:

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.

Post a Comment for "Firebase Retrieving All Children Except One"