I'm using google firebase's firestore. I was wondering if there was a way to query for documents where a property/field matches a regex. Something like this:
var username_regex = /^[a-z0-9\-\_\.]{3,}$/;
firebase.firestore().collection('users')
.where("username", "==", username_regex)
.get()
Is this possible yet? if not, how likely is it that google could implement something like this?
You can add a Firestore rule that will allow you to read only valid usernames:
match /users/{userID} {
allow read: if resource.data.username.matches('^[a-z0-9-_.]{3,30}$');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With