Comparison Operators

NameDescription
$eqwhether a value is equal to the given value.
$newhether a value is not equal to the given value.
$notnegates the given comparison.
$ltwhether a value is less than the given value.
$ltewhether a value is less than or equal to the given value.
$gtwhether a value is greater than the given value.
$gtewhether a value is greater than or equal to the given value.
$startsWithwhether a string begins with the given string (case sensitive).
$istartsWithwhether a string begins with the given string (case insensitive).
$endsWithwhether a string ends with the given string (case sensitive).
$iendsWithwhether a string ends with the given string (case insensitive).
$includeswhether a string is contained within the given string (case sensitive).
$iincludeswhether a string is contained within the given string (case insensitive).
$likewhether a string fulfills the given pattern (case sensitive).
$ilikewhether a string fulfills the given pattern (case insensitive).
$regexwhether a string matches the given regular expression.
$inwhether a value matches any of the given values.
$ninwhether a value does not match any of the given values.
$textwhether the specified fields match against a full-text search of the given string.
$existswhether the record exists in the given sub-query.
$nexistswhether the record does not exists in the given sub-query.

 

Example usage for the $istartsWith and $ne comparison operators:

await this.querier.findMany( User, { $project: ['id'], $filter: { name: { $istartsWith: 'Some', $ne: 'Something' } }, $sort: { name: 1, id: -1 }, $limit: 50, } );

That ▲ code will generate this ▼ SQL for Postgres:

SELECT "id" FROM "User" WHERE ("name" ILIKE 'Some%' AND "name" <> 'Something') ORDER BY "name", "id" DESC LIMIT 50

And that same code above will generate this other ▼ SQL for MySQL, MariaDB and SQLite:

SELECT `id` FROM `User` WHERE (LOWER(`name`) LIKE 'some%' AND `name` <> 'Something') ORDER BY `name`, `id` DESC LIMIT 50