You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/api/core/03.query-syntax.mdoc
+34-18Lines changed: 34 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,8 @@ layout:
9
9
<section>
10
10
<h1>PlusAuth Query Language Reference</h1>
11
11
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.
13
14
14
15
Common features and characteristics of PQL are as following:
15
16
@@ -19,17 +20,30 @@ Common features and characteristics of PQL are as following:
5. Field grouping ( `profile[given_name = "John" AND family_name = "Doe" ]` )
21
22
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
+
```
24
38
## Common operators
25
39
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
28
42
email_verified = true
29
43
```
30
44
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
33
47
email_verified != true
34
48
```
35
49
@@ -39,37 +53,39 @@ You can use greater than (**\>**), less than (**<**), greater or equal (**\>=
39
53
40
54
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.
41
55
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
44
58
email = "johndoe@johndoe.club" OR email_verified != true
45
59
```
46
60
47
61
You can also group statements. Just wrap your condition with parentheses. Here is an example:
48
-
```
62
+
```lua
49
63
(profile.given_name = "Jane" AND profile.family_name != "Doe") OR email_verified = true
50
64
```
51
65
52
66
## Match value in a list of values
53
67
54
68
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
56
70
profile.given_name IN "John","Jane"
57
71
```
58
72
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"
60
74
61
75
## Pattern matching
62
76
63
77
`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
+
64
79
An underscore (`_`) in pattern stands for (matches) any single character; a percent sign (`%`) matches any sequence of zero or more characters.
65
80
66
-
Some examples for a user with name `abc`:
81
+
Some examples for a entity with name `abc`:
67
82
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
73
89
```
74
90
75
91
`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