wip pg.ml
This commit is contained in:
parent
c48892ca9a
commit
2433ff3932
3 changed files with 56 additions and 9 deletions
46
src/pg.ml
Normal file
46
src/pg.ml
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
(* TODO be sure to not use postgres ptime
|
||||
add a dune stanza like for prelude:
|
||||
"(flags (:standard -open Prelude))" *)
|
||||
module Caqti_type = struct
|
||||
include Caqti_type
|
||||
|
||||
(* we want to use int64 timestamps,
|
||||
not postgresql built-in timestamp type *)
|
||||
let ptime : Ptime.t Caqti_type.t =
|
||||
let encode i = Ok (Util.ptime_to_int64 i) in
|
||||
let decode = Util.ptime_of_int64 in
|
||||
Caqti_type.custom ~encode ~decode Caqti_type.(int64)
|
||||
end
|
||||
|
||||
let pg_amount : Amount.t Caqti_type.t =
|
||||
let open Amount in
|
||||
(* TODO bad int32 conversion *)
|
||||
Caqti_type.custom
|
||||
~encode:(fun amount -> Ok (amount.value, Int64.to_int32 amount.fraction))
|
||||
~decode:(fun (value, fraction) ->
|
||||
let fraction = Int64.of_int32 fraction in
|
||||
Ok { sign= None; currency= `Eur; value; fraction })
|
||||
Caqti_type.(t2 int64 int32)
|
||||
|
||||
(* WIP: minimum db functions for basic /management *)
|
||||
|
||||
let pg_todo () = assert false
|
||||
|
||||
(* signkey *)
|
||||
let activate_signing_key = pg_todo
|
||||
let lookup_signing_key = pg_todo
|
||||
let iterate_active_signkeys = pg_todo
|
||||
let insert_signkey_revocation = pg_todo
|
||||
let lookup_signkey_revocation = pg_todo
|
||||
|
||||
(* denominations *)
|
||||
let insert_denomination_info = pg_todo
|
||||
let get_denomination_info = pg_todo
|
||||
let get_denomination_by_serial = pg_todo
|
||||
let iterate_denomination_info = pg_todo
|
||||
let iterate_denominations = pg_todo
|
||||
let get_coin_denomination = pg_todo
|
||||
let insert_denomination_revocation = pg_todo
|
||||
let get_denomination_revocation = pg_todo
|
||||
let lookup_denomination_key = pg_todo
|
||||
let add_denomination_key = pg_todo
|
||||
Loading…
Add table
Add a link
Reference in a new issue