I want to check the user if exists but in case sensitive, For example= ABC
is existing and if user type abc
or Abc
than it should say that name exists
This is my current logic
company_model.companySchema.pre('save', function (next) {
try {
cModel.find({ name: this.name }, function (err, docs) {
try {
if (!docs.length) {
next();
} else {
console.log('company name exists: ', this.name);
next(new Error("Company Name exists!"));
}
} catch (e) {
console.error('error in cModel.find: ' + e.message)
}
});
} catch (e) {
console.error('error in pre save : ' + e.message)
}
});