How to filter data in firebase (web)?

0

I am new using the firebase service, well my question is how can I filter data?

That is to say if in a form I write text as I do so that I look for the text of that form in the database and then show me the possible results of my search, I clarify that it is for a web application so that I'm using HTML and JavaScript .

I use the following code to be able to connect and order the database in my project HTML :

var PalabrasRef = 
database.ref().child('Palabras').orderByKey().limitToFirst(1);
PalabrasRef.once('value', function (snapshot){
  snapshot.forEach(function(item){
    console.log(JSON.stringify(item.val()));
  });
});

(In short, I want to do the attached image only if it is obviously visible on the web)

Thank you very much in advance!

    
asked by Charlie 08.09.2017 в 23:25
source

1 answer

1

To filter the information in the Database you must use a JS API Query . For example:

   var ref = firebase.database().ref("clientes");
   ref.orderByChild("tipo_cuenta").equalTo("principal").on("child_added", 
   function(snapshot) {
     console.log(snapshot.key);
   });
    
answered by 30.09.2017 в 16:37