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