Adapter i am using is
adapter: "sails-mongo",
I am trying to query for matches, example: Assume Values in DB for field (name) are JOHN , John, JohN , john, JOhn martin
If i search with a query for name="john" results should JOHN, John, johN
In the below code i need solution with name: inputs.name case insensitive search
fn: async function (inputs, exits) {
let criteria = {
name: inputs.name,
deleteflag: false,
};
if (inputs.id) {
criteria = {
...criteria,
_id: { "!=": inputs.id },
};
}
var existinPerson = await Person.find({
where: criteria,
});
if (existinPerson && existinPerson.length) {
return exits.success({ isPersonUnique: false });
} else {
return exits.success({ isPersonUnique: true });
}
},
I used
name: { like: inputs.marketName },
instead of name: inputs.name,
and for fetching i used .meta({ makeLikeModifierCaseInsensitive: true })
...
Finally this solution worked well for my scenario
var existinPerson = await Person.find({ where: criteria, }).meta({ makeLikeModifierCaseInsensitive: true });