Skip to content

Commit

Permalink
example/h-sql: document Lwt.bind
Browse files Browse the repository at this point in the history
  • Loading branch information
asymmetric authored Dec 10, 2024
1 parent da94944 commit e072249
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions example/h-sql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ let list_comments =
(T.unit ->* T.(tup2 int string))
"SELECT id, text FROM comment" in
fun (module Db : DB) ->
let%lwt comments_or_error = Db.collect_list query () in
Caqti_lwt.or_fail comments_or_error
Lwt.bind (Db.collect_list query ()) Caqti_lwt.or_fail
let add_comment =
let query =
Expand Down Expand Up @@ -79,6 +78,9 @@ comments!

<br>

Note that the `let%lwt` syntax is syntactic sugar for `Lwt.bind`, so the two forms above are equivalent (a third option would be using `>>=`). For more information, see [here](https://ocsigen.org/lwt/latest/api/Lwt#3_Callbacks).


We take the opportunity to try out
[`Dream.sql_sessions`](https://aantron.github.io/dream/#val-sql_sessions), which
stores session data persistently in `db.sqlite`. See example
Expand Down

0 comments on commit e072249

Please sign in to comment.