I have been using Firebase Real Time Fatabase for a while and I come across Cloud Firestore today. I can\'t figure out on how to use LIKE operator on Firestore.
Fir
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 <
.
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.
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')
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