I am implementing a web app using MEAN Stack with Angular 6. There I want to save names. In my current application 'A' and 'a' save as two different names. I want to identify 'A' and 'a' as one value when finding and saving in database. Following is my corresponding routes.
/* SAVE Practice. */
router.post("/save", function (req, res) {
var mod = new practice(req.body);
practice.findOneAndUpdate({
practiceName: req.body.practiceName
},
req.body,
{
upsert: true, new: true
},
function (err, data) {
if (err) {
res.send(err);
} else {
res.send(mod);
}
});
});
This is the corresponding method in .ts file.
save(practice: NgForm) {
if (practice.value.practiceName != "" && practice.value != null) {
this.practiceService.savePractice(practice.value).subscribe(res => {
this.getPractices();
}, (err) => {
console.log(err);
});
}
}
Does anyone knows a method to achieve case insensitivity in MongoDB ?