How does Firestore query operation strings treat d

2019-08-20 15:35发布

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?

1条回答
倾城 Initia
2楼-- · 2019-08-20 16:26

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.

查看更多
登录 后发表回答