I’d like to set a mongoDb request ignoring capitals
If I only have one user with test username
db.users.find(
{ username: "test" }
)
will return something
I’d like to return the profile test with
db.users.find(
{ username: "Test" }
)
or
db.users.find(
{ username: "tEsT" }
)
But I don”t know I to ignore capitals
same problem if I have a username Toby I’d like to find with
db.users.find(
{ username: "toby" }
)
Thanks
You can use regex to ignore capitals like:
Whereby the
ioption state case insensitive. This however is not very index friendly.A better option is to do this client side. Normalise your case so that everything is either lower case or upper case. That way you can just test as normal.