remove ';' from queries

This commit is contained in:
Swrup 2022-04-04 21:15:04 +02:00
parent e774ca5a08
commit c7582c958c
5 changed files with 77 additions and 78 deletions

View file

@ -47,150 +47,149 @@ module Q = struct
(Caqti_type.unit ->. Caqti_type.unit) (Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS post_user (post_id TEXT, user_id TEXT, \ "CREATE TABLE IF NOT EXISTS post_user (post_id TEXT, user_id TEXT, \
PRIMARY KEY(post_id), FOREIGN KEY(user_id) REFERENCES user(user_id) ON \ PRIMARY KEY(post_id), FOREIGN KEY(user_id) REFERENCES user(user_id) ON \
DELETE CASCADE);" DELETE CASCADE)"
(* one row for each thread, with thread's data *) (* one row for each thread, with thread's data *)
let create_thread_info_table = let create_thread_info_table =
(Caqti_type.unit ->. Caqti_type.unit) (Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS thread_info (thread_id TEXT, subject TEXT, \ "CREATE TABLE IF NOT EXISTS thread_info (thread_id TEXT, subject TEXT, \
lat FLOAT, lng FLOAT, FOREIGN KEY(thread_id) REFERENCES \ lat FLOAT, lng FLOAT, FOREIGN KEY(thread_id) REFERENCES \
post_user(post_id) ON DELETE CASCADE);" post_user(post_id) ON DELETE CASCADE)"
(* map thread and reply to the thread *) (* map thread and reply to the thread *)
let create_thread_post_table = let create_thread_post_table =
(Caqti_type.unit ->. Caqti_type.unit) (Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS thread_post (thread_id TEXT, post_id TEXT, \ "CREATE TABLE IF NOT EXISTS thread_post (thread_id TEXT, post_id TEXT, \
FOREIGN KEY(thread_id) REFERENCES post_user(post_id) ON DELETE CASCADE, \ FOREIGN KEY(thread_id) REFERENCES post_user(post_id) ON DELETE CASCADE, \
FOREIGN KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE);" FOREIGN KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE)"
let create_post_replies_table = let create_post_replies_table =
(Caqti_type.unit ->. Caqti_type.unit) (Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS post_replies (post_id TEXT, reply_id TEXT, \ "CREATE TABLE IF NOT EXISTS post_replies (post_id TEXT, reply_id TEXT, \
FOREIGN KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE, \ FOREIGN KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE, \
FOREIGN KEY(reply_id) REFERENCES post_user(post_id) ON DELETE CASCADE);" FOREIGN KEY(reply_id) REFERENCES post_user(post_id) ON DELETE CASCADE)"
let create_post_citations_table = let create_post_citations_table =
(Caqti_type.unit ->. Caqti_type.unit) (Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS post_citations (post_id TEXT, cited_id TEXT, \ "CREATE TABLE IF NOT EXISTS post_citations (post_id TEXT, cited_id TEXT, \
FOREIGN KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE, \ FOREIGN KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE, \
FOREIGN KEY(cited_id) REFERENCES post_user(post_id) ON DELETE CASCADE);" FOREIGN KEY(cited_id) REFERENCES post_user(post_id) ON DELETE CASCADE)"
let create_post_date_table = let create_post_date_table =
(Caqti_type.unit ->. Caqti_type.unit) (Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS post_date (post_id TEXT, date FLOAT, FOREIGN \ "CREATE TABLE IF NOT EXISTS post_date (post_id TEXT, date FLOAT, FOREIGN \
KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE);" KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE)"
let create_post_comment_table = let create_post_comment_table =
(Caqti_type.unit ->. Caqti_type.unit) (Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS post_comment (post_id TEXT, comment TEXT, \ "CREATE TABLE IF NOT EXISTS post_comment (post_id TEXT, comment TEXT, \
FOREIGN KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE);" FOREIGN KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE)"
let create_post_tags_table = let create_post_tags_table =
(Caqti_type.unit ->. Caqti_type.unit) (Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS post_tags (post_id TEXT, tag TEXT, FOREIGN \ "CREATE TABLE IF NOT EXISTS post_tags (post_id TEXT, tag TEXT, FOREIGN \
KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE);" KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE)"
let create_report_table = let create_report_table =
(Caqti_type.unit ->. Caqti_type.unit) (Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS report (user_id TEXT, reason TEXT, date \ "CREATE TABLE IF NOT EXISTS report (user_id TEXT, reason TEXT, date \
FLOAT,post_id TEXT, FOREIGN KEY(post_id) REFERENCES post_user(post_id) \ FLOAT,post_id TEXT, FOREIGN KEY(post_id) REFERENCES post_user(post_id) \
ON DELETE CASCADE, FOREIGN KEY(user_id) REFERENCES user(user_id) ON \ ON DELETE CASCADE, FOREIGN KEY(user_id) REFERENCES user(user_id) ON \
DELETE CASCADE);" DELETE CASCADE)"
let upload_report = let upload_report =
(Caqti_type.(tup4 string string float string) ->. Caqti_type.unit) (Caqti_type.(tup4 string string float string) ->. Caqti_type.unit)
"INSERT INTO report VALUES (?,?,?,?);" "INSERT INTO report VALUES (?,?,?,?)"
let ignore_report = let ignore_report =
(Caqti_type.string ->. Caqti_type.unit) (Caqti_type.string ->. Caqti_type.unit) "DELETE FROM report WHERE post_id=?"
"DELETE FROM report WHERE post_id=?;"
let get_reports = let get_reports =
(Caqti_type.unit ->* Caqti_type.(tup4 string string float string)) (Caqti_type.unit ->* Caqti_type.(tup4 string string float string))
"SELECT * FROM report;" "SELECT * FROM report"
let upload_post_id = let upload_post_id =
(Caqti_type.(tup2 string string) ->. Caqti_type.unit) (Caqti_type.(tup2 string string) ->. Caqti_type.unit)
"INSERT INTO post_user VALUES (?,?);" "INSERT INTO post_user VALUES (?,?)"
let upload_thread_info = let upload_thread_info =
(Caqti_type.(tup4 string string float float) ->. Caqti_type.unit) (Caqti_type.(tup4 string string float float) ->. Caqti_type.unit)
"INSERT INTO thread_info VALUES (?,?,?,?);" "INSERT INTO thread_info VALUES (?,?,?,?)"
let upload_thread_post = let upload_thread_post =
(Caqti_type.(tup2 string string) ->. Caqti_type.unit) (Caqti_type.(tup2 string string) ->. Caqti_type.unit)
"INSERT INTO thread_post VALUES (?,?);" "INSERT INTO thread_post VALUES (?,?)"
let upload_post_reply = let upload_post_reply =
(Caqti_type.(tup2 string string) ->. Caqti_type.unit) (Caqti_type.(tup2 string string) ->. Caqti_type.unit)
"INSERT INTO post_replies VALUES (?,?);" "INSERT INTO post_replies VALUES (?,?)"
let upload_post_comment = let upload_post_comment =
(Caqti_type.(tup2 string string) ->. Caqti_type.unit) (Caqti_type.(tup2 string string) ->. Caqti_type.unit)
"INSERT INTO post_comment VALUES (?,?);" "INSERT INTO post_comment VALUES (?,?)"
let upload_post_tag = let upload_post_tag =
(Caqti_type.(tup2 string string) ->. Caqti_type.unit) (Caqti_type.(tup2 string string) ->. Caqti_type.unit)
"INSERT INTO post_tags VALUES (?,?);" "INSERT INTO post_tags VALUES (?,?)"
let upload_post_date = let upload_post_date =
(Caqti_type.(tup2 string float) ->. Caqti_type.unit) (Caqti_type.(tup2 string float) ->. Caqti_type.unit)
"INSERT INTO post_date VALUES (?,?);" "INSERT INTO post_date VALUES (?,?)"
let get_post_user_id = let get_post_user_id =
(Caqti_type.string ->! Caqti_type.string) (Caqti_type.string ->! Caqti_type.string)
"SELECT user_id FROM post_user WHERE post_id=?;" "SELECT user_id FROM post_user WHERE post_id=?"
let get_post_comment = let get_post_comment =
(Caqti_type.string ->! Caqti_type.string) (Caqti_type.string ->! Caqti_type.string)
"SELECT comment FROM post_comment WHERE post_id=?;" "SELECT comment FROM post_comment WHERE post_id=?"
let get_post_tags = let get_post_tags =
(Caqti_type.string ->* Caqti_type.string) (Caqti_type.string ->* Caqti_type.string)
"SELECT tag FROM post_tags WHERE post_id=?;" "SELECT tag FROM post_tags WHERE post_id=?"
let get_post_date = let get_post_date =
(Caqti_type.string ->! Caqti_type.float) (Caqti_type.string ->! Caqti_type.float)
"SELECT date FROM post_date WHERE post_id=?;" "SELECT date FROM post_date WHERE post_id=?"
let get_post_citations = let get_post_citations =
(Caqti_type.string ->* Caqti_type.string) (Caqti_type.string ->* Caqti_type.string)
"SELECT post_id FROM post_citations WHERE post_id=?;" "SELECT post_id FROM post_citations WHERE post_id=?"
let get_post_replies = let get_post_replies =
(Caqti_type.string ->* Caqti_type.string) (Caqti_type.string ->* Caqti_type.string)
"SELECT reply_id FROM post_replies WHERE post_id=?;" "SELECT reply_id FROM post_replies WHERE post_id=?"
let get_thread_posts = let get_thread_posts =
(Caqti_type.string ->* Caqti_type.string) (Caqti_type.string ->* Caqti_type.string)
"SELECT post_id FROM thread_post WHERE thread_id=?;" "SELECT post_id FROM thread_post WHERE thread_id=?"
let count_thread_posts = let count_thread_posts =
(Caqti_type.string ->! Caqti_type.int) (Caqti_type.string ->! Caqti_type.int)
"SELECT COUNT(post_id) FROM thread_post WHERE thread_id=?;" "SELECT COUNT(post_id) FROM thread_post WHERE thread_id=?"
let get_is_thread = let get_is_thread =
(Caqti_type.string ->! Caqti_type.string) (Caqti_type.string ->! Caqti_type.string)
"SELECT thread_id FROM thread_info WHERE thread_id=? LIMIT 1;" "SELECT thread_id FROM thread_info WHERE thread_id=? LIMIT 1"
let get_is_post = let get_is_post =
(Caqti_type.string ->! Caqti_type.string) (Caqti_type.string ->! Caqti_type.string)
"SELECT post_id FROM post_user WHERE post_id=? LIMIT 1;" "SELECT post_id FROM post_user WHERE post_id=? LIMIT 1"
let get_post_thread = let get_post_thread =
(Caqti_type.string ->! Caqti_type.string) (Caqti_type.string ->! Caqti_type.string)
"SELECT thread_id FROM thread_post WHERE post_id=? LIMIT 1;" "SELECT thread_id FROM thread_post WHERE post_id=? LIMIT 1"
let get_thread_info = let get_thread_info =
(Caqti_type.string ->! Caqti_type.(tup3 string float float)) (Caqti_type.string ->! Caqti_type.(tup3 string float float))
"SELECT subject,lat,lng FROM thread_info WHERE thread_id=?;" "SELECT subject,lat,lng FROM thread_info WHERE thread_id=?"
let get_threads = let get_threads =
(Caqti_type.unit ->* Caqti_type.string) "SELECT thread_id FROM thread_info;" (Caqti_type.unit ->* Caqti_type.string) "SELECT thread_id FROM thread_info"
let delete_post = let delete_post =
(Caqti_type.string ->. Caqti_type.unit) (Caqti_type.string ->. Caqti_type.unit)
"DELETE FROM post_user WHERE post_id=?;" "DELETE FROM post_user WHERE post_id=?"
end end
let () = let () =

View file

@ -18,7 +18,7 @@ module Db =
let () = let () =
let set_foreign_keys_on = let set_foreign_keys_on =
(Caqti_type.unit ->. Caqti_type.unit) "PRAGMA foreign_keys = ON;" (Caqti_type.unit ->. Caqti_type.unit) "PRAGMA foreign_keys = ON"
in in
if Result.is_error (Db.exec set_foreign_keys_on ()) then if Result.is_error (Db.exec set_foreign_keys_on ()) then
Dream.error (fun log -> log "can't set foreign_keys on") Dream.error (fun log -> log "can't set foreign_keys on")
@ -27,7 +27,7 @@ let () =
let query = let query =
(Caqti_type.unit ->. Caqti_type.unit) (Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS dream_session (id TEXT PRIMARY KEY, label \ "CREATE TABLE IF NOT EXISTS dream_session (id TEXT PRIMARY KEY, label \
TEXT NOT NULL, expires_at REAL NOT NULL, payload TEXT NOT NULL);" TEXT NOT NULL, expires_at REAL NOT NULL, payload TEXT NOT NULL)"
in in
match Db.exec query () with match Db.exec query () with
| Ok () -> () | Ok () -> ()

View file

@ -17,7 +17,7 @@ let () =
"CREATE TABLE IF NOT EXISTS msg ( msg_id TEXT, from_id TEXT, to_id TEXT, \ "CREATE TABLE IF NOT EXISTS msg ( msg_id TEXT, from_id TEXT, to_id TEXT, \
msg TEXT, PRIMARY KEY(msg_id), FOREIGN KEY(from_id) REFERENCES \ msg TEXT, PRIMARY KEY(msg_id), FOREIGN KEY(from_id) REFERENCES \
user(user_id) ON DELETE CASCADE, FOREIGN KEY(to_id) REFERENCES \ user(user_id) ON DELETE CASCADE, FOREIGN KEY(to_id) REFERENCES \
user(user_id) ON DELETE CASCADE);" user(user_id) ON DELETE CASCADE)"
in in
match Db.exec create_msg_table () with match Db.exec create_msg_table () with
| Ok () -> () | Ok () -> ()
@ -136,7 +136,7 @@ let render_one request =
let insert_msg = let insert_msg =
let insert_msg = let insert_msg =
(Caqti_type.(tup3 string string string) ->. Caqti_type.unit) (Caqti_type.(tup3 string string string) ->. Caqti_type.unit)
"INSERT INTO msg VALUES (NULL, ?, ?, ?);" "INSERT INTO msg VALUES (NULL, ?, ?, ?)"
in in
fun from_id to_id msg -> fun from_id to_id msg ->
let open Syntax in let open Syntax in

View file

@ -15,76 +15,76 @@ module Q = struct
(Caqti_type.unit ->. Caqti_type.unit) (Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS image_info (post_id TEXT, image_name TEXT, \ "CREATE TABLE IF NOT EXISTS image_info (post_id TEXT, image_name TEXT, \
image_alt TEXT, FOREIGN KEY(post_id) REFERENCES post_user(post_id) ON \ image_alt TEXT, FOREIGN KEY(post_id) REFERENCES post_user(post_id) ON \
DELETE CASCADE);" DELETE CASCADE)"
let create_content_table = let create_content_table =
(Caqti_type.unit ->. Caqti_type.unit) (Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS image_content (post_id TEXT, content TEXT, \ "CREATE TABLE IF NOT EXISTS image_content (post_id TEXT, content TEXT, \
FOREIGN KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE);" FOREIGN KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE)"
let create_thumbnail_table = let create_thumbnail_table =
(Caqti_type.unit ->. Caqti_type.unit) (Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS image_thumbnail (post_id TEXT, content TEXT, \ "CREATE TABLE IF NOT EXISTS image_thumbnail (post_id TEXT, content TEXT, \
FOREIGN KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE);" FOREIGN KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE)"
let upload_info = let upload_info =
(Caqti_type.(tup3 string string string) ->. Caqti_type.unit) (Caqti_type.(tup3 string string string) ->. Caqti_type.unit)
"INSERT INTO image_info VALUES (?,?,?);" "INSERT INTO image_info VALUES (?,?,?)"
let upload_content = let upload_content =
(Caqti_type.(tup2 string string) ->. Caqti_type.unit) (Caqti_type.(tup2 string string) ->. Caqti_type.unit)
"INSERT INTO image_content VALUES (?,?);" "INSERT INTO image_content VALUES (?,?)"
let upload_thumbnail = let upload_thumbnail =
(Caqti_type.(tup2 string string) ->. Caqti_type.unit) (Caqti_type.(tup2 string string) ->. Caqti_type.unit)
"INSERT INTO image_thumbnail VALUES (?,?);" "INSERT INTO image_thumbnail VALUES (?,?)"
let get_post_content = let get_post_content =
(Caqti_type.string ->? Caqti_type.string) (Caqti_type.string ->? Caqti_type.string)
"SELECT content FROM image_content WHERE post_id=?;" "SELECT content FROM image_content WHERE post_id=?"
let get_post_thumbnail = let get_post_thumbnail =
(Caqti_type.string ->? Caqti_type.string) (Caqti_type.string ->? Caqti_type.string)
"SELECT content FROM image_thumbnail WHERE post_id=?;" "SELECT content FROM image_thumbnail WHERE post_id=?"
let get_post_info = let get_post_info =
(Caqti_type.string ->? Caqti_type.(tup2 string string)) (Caqti_type.string ->? Caqti_type.(tup2 string string))
"SELECT image_name,image_alt FROM image_info WHERE post_id=?;" "SELECT image_name,image_alt FROM image_info WHERE post_id=?"
(*avatars*) (*avatars*)
let create_user_content_table = let create_user_content_table =
(Caqti_type.unit ->. Caqti_type.unit) (Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS user_image_content (user_id TEXT, content \ "CREATE TABLE IF NOT EXISTS user_image_content (user_id TEXT, content \
TEXT, FOREIGN KEY(user_id) REFERENCES user(user_id) ON DELETE CASCADE);" TEXT, FOREIGN KEY(user_id) REFERENCES user(user_id) ON DELETE CASCADE)"
let create_user_thumbnail_table = let create_user_thumbnail_table =
(Caqti_type.unit ->. Caqti_type.unit) (Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS user_image_thumbnail (user_id TEXT, content \ "CREATE TABLE IF NOT EXISTS user_image_thumbnail (user_id TEXT, content \
TEXT, FOREIGN KEY(user_id) REFERENCES user(user_id) ON DELETE CASCADE);" TEXT, FOREIGN KEY(user_id) REFERENCES user(user_id) ON DELETE CASCADE)"
let upload_user_content = let upload_user_content =
(Caqti_type.(tup2 string string) ->. Caqti_type.unit) (Caqti_type.(tup2 string string) ->. Caqti_type.unit)
"INSERT INTO user_image_content VALUES (?,?);" "INSERT INTO user_image_content VALUES (?,?)"
let upload_user_thumbnail = let upload_user_thumbnail =
(Caqti_type.(tup2 string string) ->. Caqti_type.unit) (Caqti_type.(tup2 string string) ->. Caqti_type.unit)
"INSERT INTO user_image_thumbnail VALUES (?,?);" "INSERT INTO user_image_thumbnail VALUES (?,?)"
let get_user_content = let get_user_content =
(Caqti_type.string ->? Caqti_type.string) (Caqti_type.string ->? Caqti_type.string)
"SELECT content FROM user_image_content WHERE user_id=?;" "SELECT content FROM user_image_content WHERE user_id=?"
let get_user_thumbnail = let get_user_thumbnail =
(Caqti_type.string ->? Caqti_type.string) (Caqti_type.string ->? Caqti_type.string)
"SELECT content FROM user_image_thumbnail WHERE user_id=?;" "SELECT content FROM user_image_thumbnail WHERE user_id=?"
let delete_user_content = let delete_user_content =
(Caqti_type.string ->. Caqti_type.unit) (Caqti_type.string ->. Caqti_type.unit)
"DELETE FROM user_image_content WHERE user_id=?;" "DELETE FROM user_image_content WHERE user_id=?"
let delete_user_thumbnail = let delete_user_thumbnail =
(Caqti_type.string ->. Caqti_type.unit) (Caqti_type.string ->. Caqti_type.unit)
"DELETE FROM user_image_thumbnail WHERE user_id=?;" "DELETE FROM user_image_thumbnail WHERE user_id=?"
end end
let () = let () =

View file

@ -16,98 +16,98 @@ module Q = struct
let create_user_table = let create_user_table =
(Caqti_type.unit ->. Caqti_type.unit) (Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS user (user_id TEXT, nick TEXT, password \ "CREATE TABLE IF NOT EXISTS user (user_id TEXT, nick TEXT, password \
TEXT, email TEXT, bio TEXT, PRIMARY KEY(user_id));" TEXT, email TEXT, bio TEXT, PRIMARY KEY(user_id))"
let create_banished_table = let create_banished_table =
(Caqti_type.unit ->. Caqti_type.unit) (Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS banished (nick TEXT, email TEXT);" "CREATE TABLE IF NOT EXISTS banished (nick TEXT, email TEXT)"
let create_metadata_table = let create_metadata_table =
(Caqti_type.unit ->. Caqti_type.unit) (Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS user_metadata (user_id TEXT, metadata TEXT, \ "CREATE TABLE IF NOT EXISTS user_metadata (user_id TEXT, metadata TEXT, \
FOREIGN KEY(user_id) REFERENCES user(user_id) ON DELETE CASCADE);" FOREIGN KEY(user_id) REFERENCES user(user_id) ON DELETE CASCADE)"
let get_metadata = let get_metadata =
(Caqti_type.string ->! Caqti_type.string) (Caqti_type.string ->! Caqti_type.string)
"SELECT metadata FROM user_metadata WHERE user_id=?;" "SELECT metadata FROM user_metadata WHERE user_id=?"
let upload_metadata = let upload_metadata =
(Caqti_type.(tup2 string string) ->. Caqti_type.unit) (Caqti_type.(tup2 string string) ->. Caqti_type.unit)
"INSERT INTO user_metadata VALUES (?, ?);" "INSERT INTO user_metadata VALUES (?, ?)"
let delete_metadata = let delete_metadata =
(Caqti_type.string ->. Caqti_type.unit) (Caqti_type.string ->. Caqti_type.unit)
"DELETE FROM user_metadata WHERE user_id=?;" "DELETE FROM user_metadata WHERE user_id=?"
let get_user_id_from_nick = let get_user_id_from_nick =
(Caqti_type.string ->! Caqti_type.string) (Caqti_type.string ->! Caqti_type.string)
"SELECT user_id FROM user WHERE nick=?;" "SELECT user_id FROM user WHERE nick=?"
let get_user_id_from_email = let get_user_id_from_email =
(Caqti_type.string ->! Caqti_type.string) (Caqti_type.string ->! Caqti_type.string)
"SELECT user_id FROM user WHERE email=?;" "SELECT user_id FROM user WHERE email=?"
let get_password = let get_password =
(Caqti_type.string ->! Caqti_type.string) (Caqti_type.string ->! Caqti_type.string)
"SELECT password FROM user WHERE user_id=?;" "SELECT password FROM user WHERE user_id=?"
let is_already_user = let is_already_user =
(Caqti_type.(tup2 string string) ->! Caqti_type.int) (Caqti_type.(tup2 string string) ->! Caqti_type.int)
"SELECT EXISTS(SELECT 1 FROM user WHERE nick=? OR email=?);" "SELECT EXISTS(SELECT 1 FROM user WHERE nick=? OR email=?)"
let upload_user = let upload_user =
( Caqti_type.(tup4 string string string Caqti_type.(tup2 string string)) ( Caqti_type.(tup4 string string string Caqti_type.(tup2 string string))
->. Caqti_type.unit ) ->. Caqti_type.unit )
"INSERT INTO user VALUES (?, ?, ?, ?, ?);" "INSERT INTO user VALUES (?, ?, ?, ?, ?)"
let list_nicks = let list_nicks =
(Caqti_type.unit ->* Caqti_type.string) "SELECT nick FROM user;" (Caqti_type.unit ->* Caqti_type.string) "SELECT nick FROM user"
let get_user = let get_user =
(* there is no "tup6" *) (* there is no "tup6" *)
( Caqti_type.string ( Caqti_type.string
->! Caqti_type.(tup4 string string string Caqti_type.(tup2 string string)) ->! Caqti_type.(tup4 string string string Caqti_type.(tup2 string string))
) )
"SELECT * FROM user WHERE user_id=?;" "SELECT * FROM user WHERE user_id=?"
let update_bio = let update_bio =
(Caqti_type.(tup2 string string) ->. Caqti_type.unit) (Caqti_type.(tup2 string string) ->. Caqti_type.unit)
"UPDATE user SET bio=? WHERE user_id=?;" "UPDATE user SET bio=? WHERE user_id=?"
let update_nick = let update_nick =
(Caqti_type.(tup2 string string) ->. Caqti_type.unit) (Caqti_type.(tup2 string string) ->. Caqti_type.unit)
"UPDATE user SET nick=? WHERE user_id=?;" "UPDATE user SET nick=? WHERE user_id=?"
let update_email = let update_email =
(Caqti_type.(tup2 string string) ->. Caqti_type.unit) (Caqti_type.(tup2 string string) ->. Caqti_type.unit)
"UPDATE user SET email=? WHERE user_id=?;" "UPDATE user SET email=? WHERE user_id=?"
let update_password = let update_password =
(Caqti_type.(tup2 string string) ->. Caqti_type.unit) (Caqti_type.(tup2 string string) ->. Caqti_type.unit)
"UPDATE user SET password=? WHERE user_id=?;" "UPDATE user SET password=? WHERE user_id=?"
let get_nick = let get_nick =
(Caqti_type.string ->! Caqti_type.string) (Caqti_type.string ->! Caqti_type.string)
"SELECT nick FROM user WHERE user_id=?;" "SELECT nick FROM user WHERE user_id=?"
let get_bio = let get_bio =
(Caqti_type.string ->! Caqti_type.string) (Caqti_type.string ->! Caqti_type.string)
"SELECT bio FROM user WHERE user_id=?;" "SELECT bio FROM user WHERE user_id=?"
let get_email = let get_email =
(Caqti_type.string ->! Caqti_type.string) (Caqti_type.string ->! Caqti_type.string)
"SELECT email FROM user WHERE user_id=?;" "SELECT email FROM user WHERE user_id=?"
let delete_user = let delete_user =
(Caqti_type.string ->. Caqti_type.unit) "DELETE FROM user WHERE user_id=?;" (Caqti_type.string ->. Caqti_type.unit) "DELETE FROM user WHERE user_id=?"
let upload_banished = let upload_banished =
(Caqti_type.(tup2 string string) ->. Caqti_type.unit) (Caqti_type.(tup2 string string) ->. Caqti_type.unit)
"INSERT INTO banished VALUES (?,?);" "INSERT INTO banished VALUES (?,?)"
let get_banished = let get_banished =
(Caqti_type.(tup2 string string) ->! Caqti_type.(tup2 string string)) (Caqti_type.(tup2 string string) ->! Caqti_type.(tup2 string string))
"SELECT * FROM banished WHERE nick=? OR email=?;" "SELECT * FROM banished WHERE nick=? OR email=?"
end end
let () = let () =