DavDeveloper
DavDeveloper

Reputation: 271

Mongoose search for lower and upper case letters

I have in my database the field "City". The field is entered by the user. How can I search with collection.find for upper and lower case independently? So that Business.find({ city : city } displays "Berlin" and "berlin" as result?

Or I need to create two request to the database, with search for upper and anotherone for lower case?

I have the latest Mongoose and NodeJS Version.

Solved found in mongoDB docs the following code which works for me

Business.find({ city : { $regex: city, $options: 'i' } }

Upvotes: 0

Views: 1879

Answers (1)

DavDeveloper
DavDeveloper

Reputation: 271

Solved

Found in MongoDB docs the following which works for me

Business.find({ city : { $regex: city, $options: 'i' } }

Upvotes: 1

Related Questions