Is it possible to query a firestore collection to get all document that starts with a specific character? For example if I have a collection "Items" that contains:
I want for example only the document starting with I I don't know how modify the query , the method charAt[0] is not recognized:
return itemRef
.doc(this.itemsId)
.collection("october")
.where(firebase.firestore.FieldPath.documentId().charAt[0], "==", randomChar)
CodePudding user response:
From the top of my head, if interested in the letter "I":
var lower = 'I';
var upper = String.fromCharCode(lower.codeUnitAt(0) 1);
itemRef
.doc(this.itemsId)
.collection("october")
.where(firebase.firestore.FieldPath.documentId() ">=", lower)
.where(firebase.firestore.FieldPath.documentId() "<", upper)
Not sure, what happens in case of the letter Z.