| (struct | | datadef (parts query-string result-func sql-select) |
|
| #:transparent) |
| parts : (listof datadef-part?) |
| query-string : string? |
| | result-func | | : | | | (->i () (#:where [query-where (or/c false? string?)] | | #:order-by [query-order-by (or/c false? string?)] | | #:group-by [query-group-by (or/c false? string?)] | | #:limit [query-limit (or/c false? integer?)] | | #:mutable [mutable boolean?] | | #:json [json? boolean?]) #:rest [query-args (listof any/c)] | | [result (or/c list? vector? hash? false?)]) |
|
|
| sql-select : sql-select? |
Datadef
struct holding information about a datadef with functions to
query the database and return a properly formatted data structure.
(define-conversion predicate procedure)
|
| |
| | procedure | | : | | (-> any/c any) |
|
| (build-select-query | [ | str | | | | | | | | #:columns columns | | | | | | | | #:from tables | | | | | | | | #:where where | | | | | | | | #:order-by order-by | | | | | | | | #:group-by group-by | | | | | | | | #:limit limit]) | | → | | string? |
|
| str : string? = "" |
| columns : (or/c string? (listof any/c)) = #f |
| tables : (or/c false? string?) = #f |
| where : (or/c false? string?) = #f |
| order-by : (or/c false? string?) = #f |
| group-by : (or/c false? string?) = #f |
| limit : (or/c false? integer?) = #f |
Creates a query
string based on provided arguments.
#:columns and
#:from must be provided if initial string
(
str) is not supplied.
If
str is provided,
#:columns and
#:from must
not be supplied.
#:columns can be a string or a datadef.
Accepts a query string and returns a list of strings, which can be used in scribble
documentation.
| (get-formatted-result | | datadef-part-list | | | | | iter-func | | | | | rows | | | | | json? | | | | | #:single-ret-val single-ret-val | | | | | #:single-ret-val/f single-ret-val/f | | | | | #:ret-type ret-type | | | | [ | #:custom-iter-func custom-iter-func]) | |
|
| → (or/c list? hash? vector? false?) |
| datadef-part-list : (listof datadef-part?) |
| iter-func : (-> (listof datadef-part?) vector? boolean? (or/c vector? list? hash?)) |
| rows : (listof vector?) |
| json? : boolean? |
| single-ret-val : boolean? |
| single-ret-val/f : boolean? |
| ret-type : procedure? |
|
Formats db rows and returns a result based on the datadef’s return type.
Returns appropriate function for iterating over db rows based on the given
datadef’s return type.
(get-mock-data datadef-part-list position) → any
|
| datadef-part-list : (or/c (listof datadef-part?) (listof any/c)) |
|
(datadef:ensure-json-func) → procedure?
|
| (datadef:ensure-json-func datadef:ensure-json-func) → void? |
| datadef:ensure-json-func : procedure? |
Parameter holding the function that will be used when
#:json #t is specified in the datadef result function.