8.16.0.1
define-query
(require db/define-query) | package: define-query-lib |
This module provides utilities for turning ".sql" files into virtual-statements in a way that cooperates with raco dist.
syntax
(define-query-definer define-id path-expr)
path-expr : (or/c path? path-string?)
Binds define-id as a form that defines queries by referencing
".sql" files located at path-expr. The referenced
files are automatically bundled together with an application during
distribution (à la define-runtime-path).
The syntax of define-id is:
syntax
binder = query-id | [query-id filename-expr]
filename-expr : path-string?
A define-id form binds the query-ids by loading the contents of their associated files (relative to path-expr) at runtime and passing those contents to virtual-statement. If a filename-expr is not provided for a binder, it defaults to the result of appending ".sql" to the string version of query-id.
For example:
(define-query-definer define-metadata-query "metadata-queries") (define-metadata-query get-metadata put-metadata) (query-exec db-conn put-metadata "example" 42) (query-value db-conn get-metadata "example")