I am looking to add a simple search field, would like to use something like
collectionRef.where(\'name\', \'contains\', \'searchTerm\')
I tried
I'm sure Firebase will come out with "string-contains" soon to capture any index[i] startAt in the string... But I’ve researched the webs and found this solution thought of by someone else set up your data like this
state = {title:"Knitting"}
...
const c = this.state.title.toLowerCase()
var array = [];
for (let i = 1; i < c.length + 1; i++) {
array.push(c.substring(0, i));
}
firebase
.firestore()
.collection("clubs")
.doc(documentId)
.update({
title: this.state.title,
titleAsArray: array
})
query like this
firebase
.firestore()
.collection("clubs")
.where(
"titleAsArray",
"array-contains",
this.state.userQuery.toLowerCase()
)