0

How does the Firestore opStr (Operation Strings) in the where query method treat different data types?

The different operation strings are: <, <=, ==, >, and >=

For number data type it is very self explanatory, but how about for the other data types? string, boolean, object, array, null, timestamp, geopoint, and reference

So for e.g. string data type, does >= mean is equal to or contains string?

So db.collection('users').where('lastname','>=','bar') would return all users that has a lastname of bar or contains bar? e.g. bar, foobar, barbaz

Does anyone know of any documentation for this specific subject?

Jo E.
  • 7,822
  • 14
  • 58
  • 94

1 Answers1

2

For string types, the >= evaluates based on the lexicographical ordering of the values.

Some examples:

  • "a" < "b"
  • "aaa" < "aab"
  • "abc" < "abcd"

And also:

  • "000" < "001"
  • "010" < "011"
  • "100" < "101"

But for example:

  • "2" > "10"

Since the "2" is alphabetically later than the "1" in unicode.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Thanks for this, very helpful. Explains a lot why I am not getting the data I am expecting. Do you have any idea for the other data types? – Jo E. Mar 27 '18 at 05:26