SQL LIKE operator in Cloud Firestore?

后端 未结 4 997
名媛妹妹
名媛妹妹 2020-11-28 14:21

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

相关标签:
4条回答
  • 2020-11-28 14:37

    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 <.

    0 讨论(0)
  • 2020-11-28 14:45

    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.

    0 讨论(0)
  • 2020-11-28 14:47

    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')
    
    0 讨论(0)
  • 2020-11-28 14:55

    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

    0 讨论(0)
提交回复
热议问题