On this page:
define-datadef
datadef:  db-rows-func
datadef:  ensure-json-func

1 datadef🔗ℹ

 (require datadef/dd) package: datadef

syntax

(define-datadef name dd #:from from #:ret-type ret-type
                        [#:provide
                         #:single-ret-val
                         #:single-ret-val/f
                         #:keys-strip-prefix
                         #:camel-case
                         #:kebab-case
                         #:snake-case
                         #:keep-dot-prefix
                         #:where where
                         #:limit limit
                         #:order-by order-by
                         #:group-by group-by
                         doc-string])
 
  name : any/c
  dd : (listof any/c)
  from : string?
  ret-type : (or/c list vector hash)
  where : string?
  limit : integer?
  order-by : string?
  group-by : string?
  doc-string : string?
Creates a datadef and a function datadef:name->result to get result of dtb-query-rows formatted with datadef-format-func based on the provided #:ret-type.

If #:provide keyword is provided, scribble documentation gets created for the constant definition datadef:name and the datadef:name->result function. Both are exported as well.

#:single-ret-val can be used to return only 1 value. If there are no query results, it returns the empty version of the provided ret-type.

#:single-ret-val/f will return #f if there are no query results.

The last optional argument doc-string can be used to provide additional documentation for the datadef with the usual scribble syntax.

parameter

(datadef:db-rows-func)  
(or/c false?
  (->i ((statement string?))
       () #:rest
       (rest (listof any/c))
       (result (listof vector?))))
(datadef:db-rows-func db-rows-func)  void?
  db-rows-func : 
(or/c false?
  (->i ((statement string?))
       () #:rest
       (rest (listof any/c))
       (result (listof vector?))))
Function used for retrieving data from the database.

parameter

(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.