I need to perform a case-insensitive find. But I am getting a case-insensitive "like" returned, where things that are "like" my string match
I can overcome this in the console or tool by adding ^ and $ - however I cannot figure out how to do that in code, when Im passing a var into the query.
module.exports.getCollege = function( name, callback ) {
const query = [
{
$match: {
'name': { $regex: name, $options: 'i' }
}
},
{
$project: {
'address': 1,
'name': 1
}
}
];
College.aggregate( query ).exec( callback );
}
This returns
University of Michigan (object), University of Michigan Flint campus (object)
I just want University of Michigan (object)
How do I get a LITERAL match, but case insensitive???
+++++++++++++++++++++++++++
Response to D. SM - "use collation..."
Returns correct because string is correct..