SQL LIKE statement in Cloud Firestore?

I have been using Firebase Real Time Fatabase for a while, and today I come across Cloud Firestore. I cannot figure out how to use the LIKE operator on Firestore.

Firebase Real Time Database

ref.child('user').orderByChild('name').startAt(name).endAt(name+'\uf8ff') 

In Cloud Firestore I tried

 userRef.where('name', '>=', name); <br> userRef.where('name', '<=', name); 

But that will not work.

+20
database firebase google-cloud-firestore
source share
4 answers

To solve this problem, you need to change the orderByChild function with orderBy . So please use the following code:

 ref.collection('user').orderBy('name').startAt(name).endAt(name+'\uf8ff') 
+18
source share

There is no LIKE equivalent, but you can configure prefix filtering just like you do in RTDB.

The request you requested matches the equal. You must do the same with a trick and do less than < .

+5
source share

There is no such operator, valid - ==, <, <=, >, >=. Here you can find all the query restrictions in the cloud firestore: https://firebase.google.com/docs/firestore/query-data/queries

+1
source share

Note: in later versions of the cloud fire store (for example, 0.12.5), the startAt () and endAt () methods require a list of lines, not a single line.

0
source share

All Articles