I am using the below code to search users in the SQL Server DB but it throws REGEXP error.
Using loopback 3
and loopback-mssql-connecter
let searchedValue = await User.find({
where: {
or: [
{first_name: new RegExp('\\b' + req.query.s, 'i')},
{last_name: new RegExp('\\b' + req.query.s, 'i')},
{email: new RegExp('^' + req.query.s, 'i')},
],
},
});
This exact query works when it is tied to a MongoDB datasource but doesn't work when using a SQL Server datasource.
I get the below errors
Microsoft SQL Server does not support the regular expression operator
Unhandled error for request GET /api/leagues/searchusers/?s=nir:
RequestError: Incorrect syntax near 'REGEXP'.