[Vuejs]-How to search filter firebase with vue

0👍

Firebase.database.ref(‘products’) returns a Reference and there is no containing() method for a Reference.

The method that is the most similar is equalTo(), as detailed here.

If the filed which hold the value “leather shoe” is, let say, the “type” field, you would do something like:

var ref = firebase.database().ref("products");
ref.orderByChild("type").equalTo("leather shoe").on("child_added", function(snapshot) {
  console.log(snapshot.key);
});

With vuefire you would do:

var firebaseApp = firebase.initializeApp({ ... })
var db = firebaseApp.database()

var vm = new Vue({
  el: '#demo',
  firebase: 
    anArray: db.ref("products").orderByChild("type").equalTo("leather shoe")
  }
})

Leave a comment