Skip to content

Commit 2a785e0

Browse files
committed
style: add syntax highlighting to pql examples
1 parent 63fddc7 commit 2a785e0

1 file changed

Lines changed: 34 additions & 18 deletions

File tree

β€Žcontent/en/api/core/03.query-syntax.mdocβ€Ž

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ layout:
99
<section>
1010
<h1>PlusAuth Query Language Reference</h1>
1111

12-
PlusAuth provides its own [CQL](https://wikipedia.org/wiki/Contextual_Query_Language) for querying over resources in an easy way. It will be referred as **PQL (PlusAuth Query Language)** in PlusAuth documentation.
12+
PlusAuth provides its own [CQL](https://wikipedia.org/wiki/Contextual_Query_Language) for querying over resources in an easy way.
13+
It will be referred as **PQL (PlusAuth Query Language)** in PlusAuth documentation.
1314

1415
Common features and characteristics of PQL are as following:
1516

@@ -19,17 +20,30 @@ Common features and characteristics of PQL are as following:
1920
4. Supports nested properties ( `profile.name`, `metadata.color`, .etc)
2021
5. Field grouping ( `profile[given_name = "John" AND family_name = "Doe" ]` )
2122

22-
Below, you can find more examples and detailed descriptions of PQL.
23-
23+
Below, you can find more examples and detailed characteristics explanations of PQL.
24+
25+
## Values
26+
**Booleans**, **numbers** and **null** do not need any wrapping whereas all other values must be wrapped with **double quotes**.
27+
Example values:
28+
```lua
29+
null
30+
true
31+
false
32+
1
33+
0
34+
-1
35+
"string"
36+
"sentence with space"
37+
```
2438
## Common operators
2539

26-
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.
27-
```
40+
You can check equality, greatness and matching value in a list of values. Here is a sample query for retrieving entities whose email is verified.
41+
```lua
2842
email_verified = true
2943
```
3044

31-
For retrieving users whose email is NOT verified, you can use not equal operator
32-
```
45+
For retrieving entities whose email is NOT verified, you can use not equal operator
46+
```lua
3347
email_verified != true
3448
```
3549

@@ -39,37 +53,39 @@ You can use greater than (**\>**), less than (**&lt;**), greater or equal (**\>=
3953

4054
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.
4155

42-
Let's retrieve users whose email is "johndoe@johndoe.club" or whose email is not verified. Here is the query:
43-
```
56+
Let's retrieve entities which has `email` as `johndoe@johndoe.club` or which has `email_verified` field set to `false`. Here is the query:
57+
```lua
4458
email = "johndoe@johndoe.club" OR email_verified != true
4559
```
4660

4761
You can also group statements. Just wrap your condition with parentheses. Here is an example:
48-
```
62+
```lua
4963
(profile.given_name = "Jane" AND profile.family_name != "Doe") OR email_verified = true
5064
```
5165

5266
## Match value in a list of values
5367

5468
For checking value from a defined list of values PQL provides **IN** operator. You can provide list of values being separated by commas.
55-
```
69+
```lua
5670
profile.given_name IN "John","Jane"
5771
```
5872

59-
The query above will retrieve users whose given name is either "John" or "Jane"
73+
The query above will retrieve entities whose given name is either "John" or "Jane"
6074

6175
## Pattern matching
6276

6377
`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.
78+
6479
An underscore (`_`) in pattern stands for (matches) any single character; a percent sign (`%`) matches any sequence of zero or more characters.
6580

66-
Some examples for a user with name `abc`:
81+
Some examples for a entity with name `abc`:
6782

68-
```
69-
name ILIKE 'abc' => true
70-
name ILIKE 'a%' => true
71-
name ILIKE '_b_' => true
72-
name ILIKE 'c' => false
83+
```lua
84+
name ILIKE "abc" --> true
85+
name ILIKE "a%" --> true
86+
name ILIKE "_b_" --> true
87+
name ILIKE "ab" --> false
88+
name ILIKE "bc" --> false
7389
```
7490

7591
`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.

0 commit comments

Comments
 (0)