PlusAuth Query Language Reference
PlusAuth provides its own CQL for querying over resources in an easy way. It will be referred as PQL (PlusAuth Query Language) in PlusAuth documentation.
Common features and characteristics of PQL are as following:
- Consists one or more statements
- Logical connector operators (
AND
,OR
) - Common operators (
=
,!=
,<
,>
,>=
,>=
,IN
,ILIKE
) - Supports nested properties (
profile.name
,metadata.color
, .etc) - Field grouping (
profile[given_name = "John" AND family_name = "Doe" ]
)
Below, you can find more examples and detailed descriptions of PQL.
Common operators
You can check equality, greatness and matching value in a list of values. Here is a sample query for retrieving users whose email is verified.
For retrieving users whose email is NOT verified, you can use not equal operator
You can use greater than (>), less than (<), greater or equal (>=), less or equal (<=) operators in the same way.
Logical operators
In some cases you may need to have more than one condition to apply for retrieving your resources. You can use AND,OR for this purpose.
Let's retrieve users whose email is "[email protected]" or whose email is not verified. Here is the query:
You can also group statements. Just wrap your condition with parentheses. Here is an example:
Match value in a list of values
For checking value from a defined list of values PQL provides IN operator. You can provide list of values being separated by commas.
The query above will retrieve users whose given name is either "John" or "Jane"
Pattern matching
ILIKE
operator can be used for queries that are data based on pattern-matching techniques. Its result includes strings that are case-insensitive and follow the mentioned pattern. An underscore (_
) in pattern stands for (matches) any single character; a percent sign (%
) matches any sequence of zero or more characters.
Some examples for a user with name abc
:
ILIKE
pattern matching always covers the entire string. Therefore, if it's desired to match a sequence anywhere within a string, the pattern must start and end with a percent sign.
To match a literal underscore or percent sign without matching other characters, the respective character in pattern must be preceded by the escape character. The default escape character is the backslash (\
) character.
Operator | Description |
---|---|
= | Equal |
!= | Not equal |
< | Less than |
> | Greater than |
<= | Less than or equal |
>= | Greater than or equal |
AND | Checks if all the statements separated by it are true |
OR | Checks if any of the statements separated by it are true |
IN | Matches value in a list of values |