diff options
Diffstat (limited to 'src/database.gleam')
| -rw-r--r-- | src/database.gleam | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/src/database.gleam b/src/database.gleam index 07264fd..053bc28 100644 --- a/src/database.gleam +++ b/src/database.gleam @@ -8,11 +8,9 @@ pub type Counter { } pub fn setup(connection) { - let _ = + let assert Ok(_) = sqlight.exec( - "pragma foreign_keys = off; - - create table if not exists tb_count ( + "create table if not exists tb_count ( id integer primary key autoincrement not null unique, name text not null unique, num int not null default (0) @@ -64,18 +62,8 @@ pub fn get_counter(connection, name) { option.unwrap(row.2, ""), option.unwrap(row.3, ""), )) - Ok([]) -> { - wisp.log_error("Database query returned no rows unexpectedly.") - - Error("Unreachable entity") - } - Ok([_, _, ..]) -> { - wisp.log_error("Database query returned multiple rows unexpectedly.") - - Error("Unreachable entity") - } - Error(_) -> { - wisp.log_error("Database query failed.") + _ -> { + wisp.log_error("Database query failed or returned unexpected rows.") Error("Database operation failed") } |