Skip to content

Commit c67aa7b

Browse files
Don't use options
1 parent 2353861 commit c67aa7b

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

gleam.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name = "espresso_pgo_wrapper"
2-
version = "0.0.3"
2+
version = "0.0.4"
33
description = "Simple wrapper around the espresso PGO tool"
44

55
# Fill out these fields if you intend to generate HTML documentation or publish

src/database.gleam

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import gleam/pgo.{Connection}
55
import gleam/list
6-
import gleam/option.{None, Option}
76
import gleam/io
87
import database/query.{Query}
98
import database/schema.{Schema}
@@ -53,17 +52,17 @@ pub fn all(q: Query(a), db: Connection) -> Result(List(a), Nil) {
5352
/// |> where([#("title ilike '%$1%'", [pgo.text(title)])])
5453
/// |> database.one(db)
5554
/// ```
56-
pub fn one(q: Query(a), db: Connection) -> Option(a) {
55+
pub fn one(q: Query(a), db: Connection) -> Result(a, Nil) {
5756
let sql = query.build(q)
5857
case pgo.execute(sql, db, q.bindings, q.from.decoder) {
5958
Ok(result) -> {
6059
result.rows
6160
|> list.first()
62-
|> option.from_result()
6361
}
6462

65-
Error(_e) -> {
66-
None
63+
Error(e) -> {
64+
io.debug(e)
65+
Error(Nil)
6766
}
6867
}
6968
}

0 commit comments

Comments
 (0)