Filter Operators
Used in the filter parameter of APIs like find, findOne, findAndCount, count of a Repository:
To support JSON serialization, NocoBase identifies query operators with a string prefixed with $.
Additionally, NocoBase provides an API to extend operators, see db.registerOperators() for details.
General Operators
$eq
Checks if the field value is equal to the specified value. Equivalent to SQL's =.
Example
Equivalent to title: 'The Great Gatsby'.
$ne
Checks if the field value is not equal to the specified value. Equivalent to SQL's !=.
Example
$is
Checks if the field value is the specified value. Equivalent to SQL's IS.
Example
$not
Checks if the field value is not the specified value. Equivalent to SQL's IS NOT.
Example
$col
Checks if the field value is equal to the value of another field. Equivalent to SQL's =.
Example
$in
Checks if the field value is in the specified array. Equivalent to SQL's IN.
Example
$notIn
Checks if the field value is not in the specified array. Equivalent to SQL's NOT IN.
Example
$empty
Checks if a general field is empty. For a string field, it checks for an empty string. For an array field, it checks for an empty array.
Example
$notEmpty
Checks if a general field is not empty. For a string field, it checks for a non-empty string. For an array field, it checks for a non-empty array.
Example
Logical Operators
$and
Logical AND. Equivalent to SQL's AND.
Example
$or
Logical OR. Equivalent to SQL's OR.
Example
Boolean Field Operators
For boolean fields type: 'boolean'
$isFalsy
Checks if a boolean field value is falsy. Field values of false, 0, and NULL are all considered $isFalsy: true.
Example
$isTruly
Checks if a boolean field value is truly. Field values of true and 1 are all considered $isTruly: true.
Example
Numeric Field Operators
For numeric fields, including:
type: 'integer'type: 'float'type: 'double'type: 'real'type: 'decimal'
$gt
Checks if the field value is greater than the specified value. Equivalent to SQL's >.
Example
$gte
Checks if the field value is greater than or equal to the specified value. Equivalent to SQL's >=.
Example
$lt
Checks if the field value is less than the specified value. Equivalent to SQL's <.
Example
$lte
Checks if the field value is less than or equal to the specified value. Equivalent to SQL's <=.
Example
$between
Checks if the field value is between the two specified values. Equivalent to SQL's BETWEEN.
Example
$notBetween
Checks if the field value is not between the two specified values. Equivalent to SQL's NOT BETWEEN.
Example
String Field Operators
For string fields, including string
$includes
Checks if the string field contains the specified substring.
Example
$notIncludes
Checks if the string field does not contain the specified substring.
Example
$startsWith
Checks if the string field starts with the specified substring.
Example
$notStatsWith
Checks if the string field does not start with the specified substring.
Example
$endsWith
Checks if the string field ends with the specified substring.
Example
$notEndsWith
Checks if the string field does not end with the specified substring.
Example
$like
Checks if the field value contains the specified string. Equivalent to SQL's LIKE.
Example
$notLike
Checks if the field value does not contain the specified string. Equivalent to SQL's NOT LIKE.
Example
$iLike
Checks if the field value contains the specified string, case-insensitive. Equivalent to SQL's ILIKE (PostgreSQL only).
Example
$notILike
Checks if the field value does not contain the specified string, case-insensitive. Equivalent to SQL's NOT ILIKE (PostgreSQL only).
Example
$regexp
Checks if the field value matches the specified regular expression. Equivalent to SQL's REGEXP (PostgreSQL only).
Example
$notRegexp
Checks if the field value does not match the specified regular expression. Equivalent to SQL's NOT REGEXP (PostgreSQL only).
Example
$iRegexp
Checks if the field value matches the specified regular expression, case-insensitive. Equivalent to SQL's ~* (PostgreSQL only).
Example
$notIRegexp
Checks if the field value does not match the specified regular expression, case-insensitive. Equivalent to SQL's !~* (PostgreSQL only).
Example
Date Field Operators
For date fields type: 'date'
$dateOn
Checks if the date field is on a specific day.
Example
$dateNotOn
Checks if the date field is not on a specific day.
Example
$dateBefore
Checks if the date field is before a specific value. Equivalent to being less than the provided date value.
Example
$dateNotBefore
Checks if the date field is not before a specific value. Equivalent to being greater than or equal to the provided date value.
Example
$dateAfter
Checks if the date field is after a specific value. Equivalent to being greater than the provided date value.
Example
$dateNotAfter
Checks if the date field is not after a specific value. Equivalent to being less than or equal to the provided date value.
Example
Array Field Operators
For array fields type: 'array'
$match
Checks if the array field's value matches the values in the specified array.
Example
$notMatch
Checks if the array field's value does not match the values in the specified array.
Example
$anyOf
Checks if the array field's value contains any of the values in the specified array.
Example
$noneOf
Checks if the array field's value contains none of the values in the specified array.
Example
$arrayEmpty
Checks if the array field is empty.
Example
$arrayNotEmpty
Checks if the array field is not empty.
Example
Association Field Operators
Used to check if an association exists. Field types include:
type: 'hasOne'type: 'hasMany'type: 'belongsTo'type: 'belongsToMany'
$exists
Association data exists
Example
$notExists
No association data exists
Example

