package caqti
Unified interface to relational database libraries
Install
Dune Dependency
Authors
Maintainers
Sources
caqti-v2.2.4.tbz
sha256=b8ea432820154ec095132c4f7b244b06cd8553e0b2035185b844d9c4f30af8bb
sha512=b7e3ad8e6a9b587db2d517e15cd42df2945148f9223b2fa6f4bc2bcdd2709d53549cca4b65e54511d22466e4c9aa7f0b9c17305a07505519d8bf81d95de629b8
doc/caqti.template/Caqti_template/Query/Infix/index.html
Module Query.Infix
Source
This module provides a terser way to compose queries. As an example, consider the dynamic construction of a simple SELECT-request which extracts a list of named columns given a corresponding row type, and where conditions are given as query templates with any values embedded:
open Caqti_template.Create
type cond =
| Column_eq : string * 'a Caqti_template.Field_type.t * 'a -> cond
let query_of_cond = function
| Column_eq (col, t, v) ->
Q.lit col @++ " = " ^++ Q.const t v
let make_simple_select conds columns row_type =
let query =
"SELECT " ^++ Q.concat ~sep:", " (List.map Q.lit columns) @++
" FROM $.foo" ^++
" WHERE " ^++ Q.concat ~sep:" AND " (List.map query_of_cond conds)
in
direct_gen T.(unit -->* row_type) (fun _ -> query)
pfx ^++ q
is q
prefixed with the literal fragment pfx
, i.e. cat (lit pfx) q
.
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>