Google Firestore: Query on substring of a property value (text search)

前端 未结 16 1589
抹茶落季
抹茶落季 2020-11-22 12:08

I am looking to add a simple search field, would like to use something like

collectionRef.where(\'name\', \'contains\', \'searchTerm\')

I tried

16条回答
  •  天涯浪人
    2020-11-22 12:34

    Late answer but for anyone who's still looking for an answer, Let's say we have a collection of users and in each document of the collection we have a "username" field, so if want to find a document where the username starts with "al" we can do something like

     FirebaseFirestore.getInstance().collection("users").whereGreaterThanOrEqualTo("username", "al")
    

提交回复
热议问题