0

I have a firebase database from which I would like to retrieve all items except the items having a specific value. A function like notEqualTo(), so to say.

firebase.database()
  .ref().child('/snippets/')
  .orderByChild('description')
  .notEqualTo('dontDisplay')
  .on('value',function(snap) {
    // Working with the right snapshot
  }

This obviously does not work since notEqualTo is not a function. I also tried passing a function to equalTo but this doesn't work either:

firebase.database()
  .ref().child('/snippets/')
  .orderByChild('description')
  .equalTo(function (descr) { descr !== 'dontDisplay'; })
  .on('value',function(snap) {
    // Working with the right snapshot
  }

What's the right way to filter on items not having the description 'dontDisplay'?

Sventies
  • 2,314
  • 1
  • 28
  • 44
  • 1
    The Firebase database cannot filter on inequality. See https://stackoverflow.com/questions/39195191/firebase-query-to-exclude-data-based-on-a-condition/39195551#39195551 – Frank van Puffelen Aug 21 '17 at 10:01
  • 1
    Unfortunately you can not make this kind of exclusions using Firebase. You have to filter the fetched data. See my answer here to a similar question: https://stackoverflow.com/a/45321719/7462753 – henrikenblom Aug 21 '17 at 09:59

0 Answers0