Logical Operators
Name | Description |
---|---|
$and | joins query clauses with a logical AND , returns records that match all the clauses. |
$or | joins query clauses with a logical OR , returns records that match any of the clauses. |
$not | joins query clauses with a logical AND , returns records that do not match all the clauses. |
$nor | joins query clauses with a logical OR , returns records that do not match any of the clauses. |
Example usage for the $and
logical operator (default operator if unspecified):
await querier.findMany( User, { $filter: { name: 'maku', creatorId: 1 }, }, ['id'] );
or the same query with an explicit $and
await querier.findMany( User, { $filter: { $and: [{ name: 'maku' }, { creatorId: 1 }] }, }, ['id'] );
That ▲ code will generate this ▼ SQL
:
SELECT `id` FROM `User` WHERE `name` = 'maku' AND `creatorId` = 1
Example usage for the $or
logical operator:
await querier.findMany( User, { $filter: { $or: [{ name: 'maku' }, { creatorId: 1 }] }, }, ['id'] );
That ▲ code will generate this ▼ SQL
:
SELECT `id` FROM `User` WHERE `name` = 'maku' OR `creatorId` = 1
Example usage for the $not
logical operator
await querier.findMany( User, { $filter: { $not: [{ name: 'maku' }, { creatorId: 1 }] }, }, ['id'] );
That ▲ code will generate this ▼ SQL
:
SELECT `id` FROM `User` WHERE NOT (`name` = 'maku' AND `creatorId` = 1)
Example usage for the $nor
logical operator
await querier.findMany( User, { $filter: { $nor: [{ name: 'maku' }, { creatorId: 1 }] }, }, ['id'] );
That ▲ code will generate this ▼ SQL
:
SELECT `id` FROM `User` WHERE NOT (`name` = 'maku' OR `creatorId` = 1)