Eduard
Eduard

Reputation: 3576

Firestore IN operator not working with boolean operators

While working with the new IN operator, I just noticed that it does not work with boolean true value.

collection
    .where( 'deleted', 'in', [ true, false ] )

This only seems to return documents that have the deleted value as false. On the other hand, it works just fine when using "false" and "true" as strings, but that's not really elegant ... isn't it?

Any clue? Is there something I'm missing from the docs?

Also, another thing that doesn't seem to work is this (from the docs):

.where( 'region', 'in', [[ 'east', 'west' ]] )

This crashes the Firebase SDK saying there's an invalid value inside the query. While this is not really important, I think it's just a mispelling on Google's part.

I've reported both issues to the Firebase team, hope you guys have some insight too.

Upvotes: 0

Views: 445

Answers (1)

Renaud Tarnec
Renaud Tarnec

Reputation: 83153

Are you sure that you use the latest JavaScript SDK version (7.5.0 at the time of writing)?

Because both the pieces of code mentioned in your question work with v7.5.0.

.where( 'deleted', 'in', [ true, false ] ) does work

And

.where( 'region', 'in', [[ 'east', 'west' ]] )

or

.where( 'region', 'in', [[ 'east', 'west' ], [ 'east', 'west', 'south' ]] )

do work as well (since v7.4.0 see the doc: "The in query operator now accepts nested arrays"). However, in this case "the clause [shall] match for an exact match of array length, order, and values."

Upvotes: 2

Related Questions