open Orm
structure T = Table(struct
val cols = {A = local [int] _,
B = local [string] _}
end)
structure S = Table(struct
val cols = {C = T.id,
D = local [float] _}
end)
fun action () =
r1 <- T.create {A = 3, B = "Hi"};
T.save (r1 -- #B ++ {B = "Bye"});
r2 <- T.create {A = 4, B = "Why"};
r3 <- T.create {A = 66, B = "Hi"};
s <- S.create {C = r1.Id, D = 45.67};
ls <- T.list;
ls' <- T.search (T.eq T.cols.B.Col "Hi");
lsS <- S.list;
lsS <- List.mapM (fn r => p <- S.cols.C.Parent r; return (r, p)) lsS;
T.delete r1;
T.delete r2;
T.delete r3;
S.delete s;
return
{List.mapX (fn r => {[r.A]}: {[r.B]}) ls}
{List.mapX (fn r => {[r.A]}: {[r.B]}) ls'}
{List.mapX (fn (s, ro) => {[s.D]}: {case ro of
None => No parent
| Some r => {[r.B]}}
) lsS}
fun main () = return