[Vuejs]-Retrieve child just when value change firebase vue

0👍

Instead of using the on() method to observe events in the entire postRef node, you should filter the data, as explained here: https://firebase.google.com/docs/database/web/lists-of-data#filtering_data

So you could do something like the following, in order to filter data and to only listen to events that correspond to a change from status == false to status == true:

reading() {
            this.postRef.orderByChild('status').equalTo(true).on('child_added', snapshot => {
                this.posts.push(snapshot.val());
                this.key.push(snapshot.key);
            })

Leave a comment