This commit is contained in:
parent
e9b7142412
commit
bb1431251c
1 changed files with 8 additions and 5 deletions
13
src/pg.ml
13
src/pg.ml
|
|
@ -12,11 +12,14 @@ module Caqti_type = struct
|
|||
|
||||
let amount : Amount.t t =
|
||||
let open Amount in
|
||||
custom
|
||||
~encode:(fun amount -> Ok (amount.value, amount.fraction))
|
||||
~decode:(fun (value, fraction) ->
|
||||
Amount.make ~sign:None ~currency:Config.currency ~value ~fraction)
|
||||
(t2 int64 int32)
|
||||
let intro value fraction =
|
||||
match make ~sign:None ~currency:Config.currency ~value ~fraction with
|
||||
| Error e -> raise (Caqti_type.Reject e)
|
||||
| Ok v -> v
|
||||
in
|
||||
let p1 t = t.value in
|
||||
let p2 t = t.fraction in
|
||||
product intro @@ proj int64 p1 @@ proj int32 p2 @@ proj_end
|
||||
|
||||
let age_mask : int t = Caqti_type.int
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue