SQL LIKE operator in Cloud Firestore?
Solution 1:
To solve this, you need to change orderByChild
function with orderBy
. So please use the following code:
ref.collection('user').orderBy('name').startAt(name).endAt(name+'\uf8ff')
Solution 2:
There isn't an equivalent to LIKE, but you can do prefix filtering in the same way you do it in RTDB.
The query you have written is the same as equals. You need to do the same end by trick and do just less than <
.
Solution 3:
There's no such operator, allowed ones are ==, <, <=, >, >=.
Here you can find all the limitations of queries in cloud firestore: https://firebase.google.com/docs/firestore/query-data/queries
Solution 4:
FYI: With the later versions of cloud firestore (e.g. 0.12.5), the startAt() and endAt() methods require a list of strings, not a single string.