My first post!
If the results of the query must contain the upper or lower case of some text, you will need to do a case-insensitive RegExp search:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const someText = 'black'; | |
const pattern = new RegExp('.*' + someText + '.*', "i"); /* Case-insensitive RegExp search. The second argument is the case insensitive flag */ | |
Cat.find({ | |
where: { | |
adopted: false, | |
or: [ | |
{ name: { regexp: pattern } }, | |
{ description: { regexp: pattern } } | |
] | |
} | |
}); |
Note: I used MongoDB for my database.
Top comments (0)