🐿️ Type safe SQL in Gleam
846 B
33 lines
1---
2version: 1.1.8
3title: string decoding
4file: ./test/squirrel_test.gleam
5test_name: string_decoding_test
6---
7/// A row you get from running the `query` query
8/// defined in `query.sql`.
9///
10/// > 🐿️ This type definition was generated automatically using v-test of the
11/// > [squirrel package](https://github.com/giacomocavalieri/squirrel).
12///
13pub type QueryRow {
14 QueryRow(res: String)
15}
16
17/// Runs the `query` query
18/// defined in `query.sql`.
19///
20/// > 🐿️ This function was generated automatically using v-test of
21/// > the [squirrel package](https://github.com/giacomocavalieri/squirrel).
22///
23pub fn query(db) {
24 let decoder =
25 decode.into({
26 use res <- decode.parameter
27 QueryRow(res: res)
28 })
29 |> decode.field(0, decode.string)
30
31 "select 'wibble' as res"
32 |> pgo.execute(db, [], decode.from(decoder, _))
33}