Reputation: 65
I have one search functionality where when user user will type the letter it will search with mongoDB document but as per my code its only searching with some specific letter. I am explaining my code below.
Document::
{ "_id" : 1, "StoreCode" : "DKSR", "IsDeleted" : false }
{ "_id" : 2, "StoreCode" : "DKJG", "IsDeleted" : false }
MongoDB query::
search='dksr';
const aggregatePipeLine = [
{
$match: {
IsDeleted: false,
StoreCode: { $regex : new RegExp(search)}
}
},
{
$lookup: {
from: "customers",
localField: "CustomerId",
foreignField: "_id",
as: "CustInfo"
}
}
];
aggregatePipeLine.push({$sort: { UpdatedAt : -1 }});
let CustomerGroup = await CustomerGroupCollection.aggregate(aggregatePipeLine).limit(limit).skip(skip);
Here my issue is when search='DKSR'
its working as expected but if user is typing search='dksR'
no record is fetching. I need for each letter (May be capital or small) it should give the appropriate result.
Upvotes: 1
Views: 85