Only bring specific data from firebase

0

Well, I'm trying to develop an app with ionic 3 and Firebase. But I'm having problems. You are bringing all requests to all users (getAll). I wanted to know the correct way for me to bring only the user requests themselves;

  getAll() {
return this.db.list('pedidos', ref => ref.orderByChild('name'))
  .snapshotChanges()
  .map(changes => {
    return changes.map(c => ({ key: c.payload.key, ...c.payload.val() }));

  })

}

    
asked by anonymous 19.09.2018 / 16:49

1 answer

0

Try to include the user id in the function this way:

getListaUsuario() {
    var userId = firebase.auth().currentUser.uid;
    return firebase.database().ref('/pedidos/' + userId).once('value').then(function(snapshot) {
       return snapshot.val();
    });
}
    
19.09.2018 / 20:06