Ad

Retrieve Only Some Params From A Node At Firebase (web)?

Does firebase allows me to fetch only some params from a node ?

Example User has: id, name, email, birthday, zip_code

But I only want id and name for an specific search.

To get users list at web app I can do:

var database = firebase.database();
return firebase.database().ref('/users).once('value').then(function(snapshot) {
  console.log('list de users: ');
  console.log(snapshot.val());
});

But this retrieves all users params, how can I get only id and name from /users at Firebase?

Ad

Answer

You can't specify a subset of children to fetch for a single query. When you query at a location in the database, you will always get all children of that location, as deeply nested as they go.

If you only want certain children, you will have to make a separate request for each one of them at their fully specified paths.

Ad
source: stackoverflow.com
Ad