AngularFire2: query if a child exists

I plan on getting a list from my database where certain entries contain a property that can be set. I want to query and display elements that do not have this property

{
  books: {
    book_3: {
     title: "Return of The King"
    },
    book_2: {
     title: "The Two Towers"
    },
    book_1: {
     title: "The Fellowship of the Ring"
     read: 1256953732
    }
  }
}

I read the first book, and I want to display the remaining two books. In Firebase, I do:

fbl.child('books').orderByChild('read').equalTo(null).on("value", function(data) { 
 // handle data
}

And in AngularFire2, I would do something like:

this.af.database.list('books', { query: {
  orderByChild: 'read',
  equalTo: null
}});

The first method works, and I get book_2, book_3, but the AngularFire2 method returns the whole list! Is there a value that can be specified as a null value? I tried logical operations, empty lines, etc., but nothing works.

Perhaps this is a mistake.

+4
source share
2 answers

​​ - 2.0.0-beta.7 AngularFire2.

​​ this pull request - AngularFire2, 2.0.0-beta.7.

, :

this.af.database.list('books', { query: {
  orderByChild: 'read',
  equalTo: null
}});

, , , read.

+1

"" node 0 ( ) :

   af.database.list('books', { query: {
orderByChild: 'read', 
    equalTo: 0
    }
0

Source: https://habr.com/ru/post/1659510/


All Articles