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: README.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
1
# Query Parser for REST
2
2
Query Parser is a library for easy building dynamic SQL queries to Database. It provides a simple API for web-applications which needs to do some filtering throught GET queries. It is a connector between the HTTP handler and the DB engine, and manages validations and translations for user inputs.
@@ -50,9 +52,9 @@ See cmd/main.go and tests for more examples.
50
52
```
51
53
52
54
## Top level fields:
53
-
*`fields` - fields for SELECT clause separated by comma (",") Eg. `&fields=id,name`. If nothing provided use "\*" by default. Attention! If you want to use this filter you have to defaine validation func for it. Use `rqp.In()` func for limit fields for your query.
55
+
*`fields` - fields for SELECT clause separated by comma (",") Eg. `&fields=id,name`. If nothing provided will use "\*" by default. Attention! If you want to use this filter you have to define validation func for it. Use `rqp.In("id", "name")` func for limit fields for your query.
54
56
*`sort` - sorting fields list separated by comma (","). Must be validated too. Could include prefix +/- which means ASC/DESC sorting. Eg. `&sort=+id,-name` will print `ORDER BY id, name DESC`. You have to filter fields in this parameter by adding `rqp.In("id", "name")`.
55
-
*`limit` - is limit for LIMIT clause. Should be greater then 0 by default. Definition of the validation for `limit` is not required.
57
+
*`limit` - is limit for LIMIT clause. Should be greater then 0 by default. Definition of the validation for `limit` is not required. But you may use `rqp.Max(100)` to limit top threshold.
56
58
*`offset` - is offset for OFFSET clause. Should be greater then or equal to 0 by default. Definition of the validation for `offset` is not required.
57
59
58
60
## Validation modificators:
@@ -61,7 +63,7 @@ See cmd/main.go and tests for more examples.
61
63
*`:bool` - parameter must be convertable to bool type. Raise error if not.
62
64
63
65
## Supported types
64
-
-`strings` - the default type for all provided filters if not specified another. Could be compared by `eq, ne, like, ilkie, in` methods.
66
+
-`string` - the default type for all provided filters if not specified another. Could be compared by `eq, ne, like, ilike, in` methods.
65
67
-`int` - integer type. Must be specified with tag ":int". Could be compared by `eq, ne, gt, lt, gte, lte, in` methods.
66
68
-`bool` - boolean type. Must be specified with tag ":bool". Could be compared by `eq` method.
0 commit comments