Skip to main content
Version: v2.x

Permissions Operators

Common operators (all column types except json, jsonb)​

OperatorPostgreSQL equivalentDescription
_eq=Equal to
_ne<>Not equal to
_gt>Greater than
_lt<Less than
_gte>=Greater than or equal to
_lte<=Less than or equal to
_inINIn array
_ninNOT INNot in array
_is_nullIS NULLIs null

Logical operators​

OperatorPostgreSQL equivalentDescription
_andANDLogical AND
_orORLogical OR
_notNOTLogical NOT

Exists operator​

OperatorPostgreSQL equivalentDescription
_existsEXISTSCheck for existence

String extended operators​

OperatorPostgreSQL equivalentDescription
_likeLIKELike
_nlikeNOT LIKENot like
_ilikeILIKECase insensitive like
_nilikeNOT ILIKECase insensitive not like
_similarSIMILAR TOSimilar
_nsimilarNOT SIMILAR TONot similar
_regex~Regular expression match
_iregex~*Case insensitive regex
_nregex!~Not regex
_niregex!~*Not case insensitive regex
Similar

The SIMILAR TO operator in SQL returns true or false depending on whether its pattern matches the given string. It is much the same as LIKE, except that it interprets the pattern using SQL99's definition of a regular expression. SQL99's regular expressions are a curious cross between LIKE notation and common regular expression notation.

Column comparison operators​

OperatorDescription
_ceqColumn equal to
_cneColumn not equal to
_cgtColumn greater than
_cltColumn less than
_cgteColumn greater than or equal to
_clteColumn less than or equal to

Column comparison operators compare a column with another column of the same type, instead of with a static value or a session variable. The right-hand side names the column to compare with:

  • "column_name" or ["column_name"] refers to a column of the table the expression is evaluated on at that point. At the top level that is the table the permission is defined on; inside a relationship it is the related table.
  • ["$", "column_name"] refers to a column of the table the permission is defined on (the root table), also from inside a relationship.

For example, this select permission on an articles table only allows the rows that were updated after they were published:

{
"updated_at": {
"_cgt": "published_at"
}
}

And this select permission on articles only allows the articles whose author belongs to the same team as the article, by comparing a column of the related author table with a column of articles itself:

{
"author": {
"team_id": {
"_ceq": ["$", "team_id"]
}
}
}

The two columns must have exactly the same type, so for example an integer column cannot be compared with a bigint column. Paths through relationships, such as ["$", "author", "team_id"], are not supported on the right-hand side.

Column comparison operators are supported on Postgres-compatible databases and data connectors, but not on SQL Server or BigQuery.

JSONB operators​

OperatorPostgreSQL equivalentDescription
_is_nullIS NULLIs null
_contains@&gt;Contains (Does the left JSON value contain within it the right value?)
_contained_in&lt;@Contained in (Is the left JSON value contained within the right value?)
_has_key?Has key (Does the key/element string exist within the JSON value?)
_has_keys_any?|Has keys any (Do any of these key/element strings exist?)
_has_keys_all?&amp;Has keys all (Do all of these key/element strings exist?)