Cannot use Dollar-Quoted values with like expressions
Summary
Using dollar quoted values in criteria object breaks conditions that use like
operator due to the surrounding single-quotes
Example
Database setup
CREATE TABLE things (
id SERIAL PRIMARY KEY,
stuff TEXT
);
Code demonstrating the behavior
const userSearch = "hack"
db.things.find({ "stuff like": "$$%" + userSearch + "%$$" });
Expected behavior
generate WHERE stuff like $$%hack%$$
without the surrounding single-quotes
Actual behavior
generates WHERE stuff like '$$%hack%$$'
Additional context
cannot use the dollar quotes inside the like expression eg WHERE stuff like '%$$hack$$%'
as it doesn't provided the expected behavior
Maybe I'm not aware of another approach.
For now I'm defaulting to db.query
but it would be nice to be able use .find