Packages

A simple query builder

Current section

Files

Jump to
quieres README.md
Raw

README.md

# quieres
[![Package Version](https://img.shields.io/hexpm/v/quieres)](https://hex.pm/packages/quieres)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/quieres/)
<img src="https://tangled.org/ollie.earth/quieres/raw/main/public/quieres.png" alt="dog with a blunt. asking 'quieres'" width="200" height="200">
## Example
```sh
gleam add quieres@1
```
```gleam
let assert Ok(req) = request.to("https://page.example/")
req
|> request.set_method(http.Get)
|> request.set_query(
[
quieres.int("pk", 73),
quieres.float("pi", 3.14159),
quieres.optional(quieres.string, "package", option.Some("quieres")),
quieres.optional(quieres.bool, "is-cool", option.Some(True)),
quieres.optional(quieres.int, "im-not-going", option.None),
]
|> quieres.format(),
)
|> httpc.send
```
Here, `set_query` gets the following:
```gleam
[
#("pk", "73"),
#("pi", "3.14159"),
#("package", "quieres"),
#("is-cool", "True"),
]
```
Note that `im-not-going` doesn't show up at all.
Further documentation can be found at <https://hexdocs.pm/quieres>.