8.18
top
← prev up next →

define-queryπŸ”— i

Bogdan Popa <bogdan@defn.io>

This module provides utilities for turning ".sql" files into virtual-statement s in a way that cooperates with raco dist.

syntax

( define-query-definer define-idpath-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

( define-idbinder...+)

binder = query-id
| [query-idfilename-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-connput-metadata"example"42)
(query-value db-connget-metadata"example")
top
← prev up next →

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /