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: docs/filtering.rst
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ So this is a first example:
24
24
25
25
.. sourcecode:: http
26
26
27
-
GET /user?filter=[{"name":"first_name","op":"eq","val":"John"}] HTTP/1.1
27
+
GET /users?filter=[{"name":"first_name","op":"eq","val":"John"}] HTTP/1.1
28
28
Accept: application/vnd.api+json
29
29
30
30
In this example we want to retrieve user records for people named John. So we can see that the filtering interface completely fits that of SQLAlchemy: a list a filter information.
@@ -37,7 +37,7 @@ Example with field:
37
37
38
38
.. sourcecode:: http
39
39
40
-
GET /user?filter=[{"name":"first_name","op":"eq","field":"birth_date"}] HTTP/1.1
40
+
GET /users?filter=[{"name":"first_name","op":"eq","field":"birth_date"}] HTTP/1.1
41
41
Accept: application/vnd.api+json
42
42
43
43
In this example, we want to retrieve people whose name is equal to their birth_date. This example is absurd, it's just here to explain the syntax of this kind of filter.
@@ -74,7 +74,7 @@ There is a shortcut to achieve the same filtering:
74
74
75
75
.. sourcecode:: http
76
76
77
-
GET /user?filter=[{"name":"group.name","op":"ilike","val":"%admin%"}] HTTP/1.1
77
+
GET /users?filter=[{"name":"group.name","op":"ilike","val":"%admin%"}] HTTP/1.1
78
78
Accept: application/vnd.api+json
79
79
80
80
You can also use boolean combination of operations:
@@ -116,22 +116,22 @@ You can also use boolean combination of operations:
116
116
117
117
.. sourcecode:: http
118
118
119
-
GET /user?filter=[{"name":"group.name","op":"ilike","val":"%admin%"},{"or":[{"not":{"name":"first_name","op":"eq","val":"John"}},{"and":[{"name":"first_name","op":"like","val":"%Jim%"},{"name":"date_create","op":"gt","val":"1990-01-01"}]}]}] HTTP/1.1
119
+
GET /users?filter=[{"name":"group.name","op":"ilike","val":"%admin%"},{"or":[{"not":{"name":"first_name","op":"eq","val":"John"}},{"and":[{"name":"first_name","op":"like","val":"%Jim%"},{"name":"date_create","op":"gt","val":"1990-01-01"}]}]}] HTTP/1.1
120
120
Accept: application/vnd.api+json
121
121
122
122
123
123
Filtering records by a field that is null
124
124
125
125
.. sourcecode:: http
126
126
127
-
GET /user?filter=[{"name":"name","op":"is_","val":null}] HTTP/1.1
127
+
GET /users?filter=[{"name":"name","op":"is_","val":null}] HTTP/1.1
128
128
Accept: application/vnd.api+json
129
129
130
130
Filtering records by a field that is not null
131
131
132
132
.. sourcecode:: http
133
133
134
-
GET /user?filter=[{"name":"name","op":"isnot","val":null}] HTTP/1.1
134
+
GET /users?filter=[{"name":"name","op":"isnot","val":null}] HTTP/1.1
135
135
Accept: application/vnd.api+json
136
136
137
137
@@ -172,22 +172,22 @@ For example
172
172
173
173
.. sourcecode:: http
174
174
175
-
GET /user?filter[first_name]=John HTTP/1.1
175
+
GET /users?filter[first_name]=John HTTP/1.1
176
176
Accept: application/vnd.api+json
177
177
178
178
equals:
179
179
180
180
.. sourcecode:: http
181
181
182
-
GET /user?filter=[{"name":"first_name","op":"eq","val":"John"}] HTTP/1.1
182
+
GET /users?filter=[{"name":"first_name","op":"eq","val":"John"}] HTTP/1.1
183
183
Accept: application/vnd.api+json
184
184
185
185
186
186
You can also use more than one simple filter in a request:
187
187
188
188
.. sourcecode:: http
189
189
190
-
GET /user?filter[first_name]=John&filter[gender]=male HTTP/1.1
190
+
GET /users?filter[first_name]=John&filter[gender]=male HTTP/1.1
191
191
Accept: application/vnd.api+json
192
192
193
193
which is equal to:
@@ -209,17 +209,17 @@ which is equal to:
209
209
210
210
.. sourcecode:: http
211
211
212
-
GET /user?filter=[{"name":"first_name","op":"eq","val":"John"},{"name":"gender","op":"eq","val":"male"}] HTTP/1.1
212
+
GET /users?filter=[{"name":"first_name","op":"eq","val":"John"},{"name":"gender","op":"eq","val":"male"}] HTTP/1.1
213
213
214
214
You can also use relationship attribute in a request:
215
215
216
216
.. sourcecode:: http
217
217
218
-
GET /user?filter[group_id]=1 HTTP/1.1
218
+
GET /users?filter[group_id]=1 HTTP/1.1
219
219
Accept: application/vnd.api+json
220
220
221
221
which is equal to:
222
222
223
223
.. sourcecode:: http
224
224
225
-
GET /user?filter=[{"name":"group.id","op":"eq","val":"1"}] HTTP/1.1
225
+
GET /users?filter=[{"name":"group.id","op":"eq","val":"1"}] HTTP/1.1
0 commit comments