need help with mongodb

My collection document look like this
{
_id : 1,
hotelName:"Burger King",
cost : 200
},
{
_id : 2,
hotelName:"misu",
cost : 200
}
{
_id : 1,
hotelName:"Burger King",
cost : 200
},
{
_id : 2,
hotelName:"misu",
cost : 200
}
Express code :
js
Hotelname ="Misu"
await Model.find({
hotelName : {
$regex : Hotelname , $options : 'i' } })
js
Hotelname ="Misu"
await Model.find({
hotelName : {
$regex : Hotelname , $options : 'i' } })
I use regEx to remove white spaces on hotelName variable and make it as lower case too before using on $regex query So the problem is if I search Misu it works but it won't work when Burger King because it has space between the words ! Is there any solution or should I change the values in document
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server