Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
These quick fixes get the example code working on 0.30.5 due to changes made in gleam-lang/gleam#2047.

I added the imports, as it took a while for me (learning gleam) to figure out the errors and to add that, so hopefully it helps someone new. I don't think it'd be adverse to anyone else.
  • Loading branch information
ukd1 authored and lpil committed Aug 30, 2023
1 parent 886220e commit 37ae203
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ Works on Erlang or JavaScript running on Deno.
```sh
gleam add sqlight
```

```gleam
import gleam/dynamic
import sqlight
pub fn main() {
use conn <- sqlight.with_connection(":memory:")
let cat_decoder = dynamic.tuple2(dynamic.string, dynamic.int)
Expand All @@ -23,13 +27,13 @@ pub fn main() {
('Biffy', 10),
('Ginny', 6);
"
assert Ok(Nil) = sqlight.exec(sql, conn)
let assert Ok(Nil) = sqlight.exec(sql, conn)
let sql = "
select name, age from cats
where age < ?
"
assert Ok([#("Nubi", 4), #("Ginny", 6)]) =
let assert Ok([#("Nubi", 4), #("Ginny", 6)]) =
sqlight.query(sql, on: conn, with: [sqlight.int(7)], expecting: cat_decoder)
}
```
Expand Down

0 comments on commit 37ae203

Please sign in to comment.