Obtain information from a node in firebase

0

How can I extract only the node information that I select in firebase? EXAMPLE:

  • -L-qKQ-UICkQ1K-QAJDx
  • name: 'Jesus'

  • -L-qKRq1_yZmTdjvRqfN

  • name: 'Moises'

I just want to extract the node '-L-qKRq1_yZmTdjvRqfN' where the name 'Moises' is

Is there any way without having to select all?

firebase.database().ref('usuarios').on('value', function(data) {
    var element = data.val();
    $.each(element, function(nodo, value) {
        if(nodo == '-L-qKRq1_yZmTdjvRqfN') console.log(value.name);
    });
});
    
asked by jsstoni 08.12.2017 в 15:53
source

1 answer

0

You can do that using the equalTo

function
firebase.database().ref('usuarios').orderByChild('name').equalTo('Moises').on('child_added', function(data) {
    var element = data.val();
    console.log(element.name);
});

Keep in mind that you can only use one condition (you can not put 2 equalTo in the same query).

    
answered by 16.12.2017 / 08:55
source