I have two Objects in my database collection.
[
{"_id" : 1, name: "notLowercased"},
{"_id" : 2, name: "lowercased"},
]
Using find and $regex to search for names that include a specific string.
data = await CatalogModel.find({name: {$regex : searcher.toString().toLowerCase()}})
For example, if the input string is "lowercased".
The result returns an array:
[
{"_id" : 2, name: "lowercased"},
]
However, I want the result to be:
[
{"_id" : 1, name: "notLowercased"},
{"_id" : 2, name: "lowercased"},
]
I understand that this happens because "notLowercased" is not lowercased.
How can I lowercase the name fields in this request?