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
) - 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.
email_verified = true
For retrieving users whose email is NOT verified, you can use not equal operator
email_verified != true
You can use greater than >, less than <, greater or equal >=, less or equal <= operators in the same way.
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.
profile.given_name IN "John","Jane"
The query above will retrieve users whose given name is either "John" or "Jane"
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:
email = "[email protected]" OR email_verified != true
You can also group statements. Just wrap your condition with parentheses. Here is an example:
(profile.given_name = "Jane" AND profile.family_name != "Doe") OR email_verified = true
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 |