File tree Expand file tree Collapse file tree 3 files changed +28
-58
lines changed Expand file tree Collapse file tree 3 files changed +28
-58
lines changed Original file line number Diff line number Diff line change 11Filtering API example
22======================
33
4- .. literalinclude :: ../examples/api_complex_filtering .py
4+ .. literalinclude :: ../examples/custom_filter_example .py
55 :language: python
66
77
8- Check existing users
8+
9+ Filter by jsonb contains
10+
11+ .. code-block :: json
12+
13+ [
14+ {
15+ "name" : " words" ,
16+ "op" : " jsonb_contains" ,
17+ "val" : {"location" : " Moscow" , "spam" : " eggs" }
18+ }
19+ ]
920
1021 Request:
1122
12- .. literalinclude :: ./http_snippets/snippets/api_filtering__get_users
23+ .. literalinclude :: ./http_snippets/snippets/api_filtering__get_users__filter_word_contains_in_array
1324 :language: HTTP
1425
1526Response:
1627
17- .. literalinclude :: ./http_snippets/snippets/api_filtering__get_users_result
28+ .. literalinclude :: ./http_snippets/snippets/api_filtering__get_users__filter_word_contains_in_array_result
1829 :language: HTTP
1930
2031
32+ Other examples
33+ --------------
2134
2235Filter by word
2336
@@ -63,26 +76,3 @@ Response:
6376
6477.. literalinclude :: ./http_snippets/snippets/api_filtering__get_users__filter_words_in_array_result
6578 :language: HTTP
66-
67-
68- Filter by any word containing value
69-
70- .. code-block :: json
71-
72- [
73- {
74- "name" : " words" ,
75- "op" : " ilike_in_str_array" ,
76- "val" : " green"
77- }
78- ]
79-
80- Request:
81-
82- .. literalinclude :: ./http_snippets/snippets/api_filtering__get_users__filter_word_contains_in_array
83- :language: HTTP
84-
85- Response:
86-
87- .. literalinclude :: ./http_snippets/snippets/api_filtering__get_users__filter_word_contains_in_array_result
88- :language: HTTP
Original file line number Diff line number Diff line change 1- GET /users ?filter=%5B%7B%22name%22%3A%22words%22%2C%22op%22%3A%22ilike_in_str_array %22%2C%22val%22%3A%22green% 22%7D%5D HTTP/1.1
1+ GET /photos ?filter=%5B%7B%22name%22%3A%22words%22%2C%22op%22%3A%22jsonb_contains %22%2C%22val%22%3A%7B%22location% 22%3A%22Moscow%22%2C%22spam%22%3A%22eggs%22% 7D%7D%5D%0A HTTP/1.1
22Content-Type: application/vnd.api+json
Original file line number Diff line number Diff line change @@ -5,42 +5,22 @@ Content-Type: application/vnd.api+json
55 "data": [
66 {
77 "attributes": {
8- "name": "John",
9- "words": [
10- "foo",
11- "bar",
12- "green-grass"
13- ]
8+ "name": "pic-qwerty",
9+ "words": {
10+ "location": "Moscow",
11+ "spam": "eggs",
12+ "foo": "bar",
13+ "qwe": "abc"
14+ }
1415 },
15- "id": "1",
16- "links": {
17- "self": "/users/1"
18- },
19- "type": "user"
20- },
21- {
22- "attributes": {
23- "name": "Sam",
24- "words": [
25- "spam",
26- "eggs",
27- "green-apple"
28- ]
29- },
30- "id": "2",
31- "links": {
32- "self": "/users/2"
33- },
34- "type": "user"
16+ "id": "7",
17+ "type": "photo"
3518 }
3619 ],
3720 "jsonapi": {
3821 "version": "1.0"
3922 },
40- "links": {
41- "self": "http://localhost:5000/users?filter=%5B%7B%22name%22%3A%22words%22%2C%22op%22%3A%22ilike_in_str_array%22%2C%22val%22%3A%22green%22%7D%5D"
42- },
4323 "meta": {
44- "count": 2
24+ "count": 1
4525 }
4626}
You can’t perform that action at this time.
0 commit comments