Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit 0d946cb7 authored by Muhammad Zaki's avatar Muhammad Zaki
Browse files

chore(server): few type fixes

parent c1f0cfa6
No related branches found
No related tags found
No related merge requests found
......@@ -3,18 +3,18 @@ module Comment = struct
end
module Q = struct
open Caqti_type.Std
open Caqti_request.Infix
module T = Caqti_type.Std
let comment =
let open Comment in
let encode { id; message } = Ok (id, message) in
let decode (id, message) = Ok { id; message } in
let rep = Caqti_type.(tup2 int string) in
custom ~encode ~decode rep
T.custom ~encode ~decode rep
let create_comment =
(unit ->. unit)
let open Caqti_request.Infix in
T.(unit ->. unit)
@@ {|
CREATE TABLE IF NOT EXISTS comment (
id SERIAL PRIMARY KEY,
......@@ -23,9 +23,12 @@ module Q = struct
|}
let insert_comment =
(string ->. unit) @@ "INSERT INTO comment (text) VALUES ($1)"
let open Caqti_request.Infix in
T.(string ->. unit) @@ "INSERT INTO comment (text) VALUES ($1)"
let select_all_comments = (unit ->* comment) @@ "SELECT id, text FROM comment"
let select_all_comments =
let open Caqti_request.Infix in
T.(unit ->* comment) @@ "SELECT id, text FROM comment"
end
let create_comment (module Db : Caqti_lwt.CONNECTION) =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment