0

I am facing a problem right now. I really don't understand where is my fault.

I try to query with library @angular/fire

Following is my query code:

return this.firestore.collection('Transaksi', ref => ref
  .where('travel', '==', travel)
  .where('waktu', 'in', [1, 5]) //this line is problem.
  .where('tanggal', '==', tanggal)
  .where('dariKota', '==', dari)
  .where('menujuKota', '==', menuju))
  .valueChanges()

But, I only get value where when waktu == 5.

If I use

return this.firestore.collection('Transaksi', ref => ref
  .where('travel', '==', travel)
  .where('waktu', '==', 1)
  .where('tanggal', '==', tanggal)
  .where('dariKota', '==', dari)
  .where('menujuKota', '==', menuju))
  .valueChanges()

I get the correct value when I use waktu == 1 or waktu == 5 (normal). But didn't get anything when I use waktu in [1, 5]. I try to use waktu in [5, 1] but got the result.

Is something there I am missing? or in angular, in still not supportted?

Syntle
  • 5,168
  • 3
  • 13
  • 34
  • As per [documentation](https://firebase.google.com/docs/firestore/query-data/queries#in_and_array-contains-any) the operator should work. Have you checked if you are using the latest Releases of the Libraries: [Node.js](https://firebase.google.com/support/release-notes/admin/node), [AngularFire](https://github.com/angular/angularfire/releases)? Additionally, is your query call exactly matching the data bound to "waktu"? I am asking this question, after stumbling across [this](https://stackoverflow.com/questions/59052349/firestore-array-contains-any-is-not-working-properly) example. – Artemis Georgakopoulou May 28 '20 at 11:45
  • @ArtemisGeorgakopoulou yes, i use latest release Node.js dan angular, use anguler fire latest too. yes, my value of `waktu` is number, so it would be no problem. as i write in my question, if i use `waktu == 5` the result came out. but not came out when `waktu in [5, 1]`. – Aziz Ainun Najib May 28 '20 at 18:47
  • Could you please try with the following code: where('waktu', 'array-contains-any', [5,1]) and let me if it works or not. – Nibrass H Jun 08 '20 at 12:10

0 Answers0