diff options
author | 2009-10-06 10:34:27 -0400 | |
---|---|---|
committer | 2009-10-06 10:34:27 -0400 | |
commit | 79edb644cdc9c2218be3c34151eb69a84fb8344e (patch) | |
tree | 8a386900871e1e5f5b8e0bc71360b35155987e1d /demo/more/orm1.ur | |
parent | 0e84370511179878aa0ebae8bf43810efac194a5 (diff) |
Initial Orm1 demo
Diffstat (limited to 'demo/more/orm1.ur')
-rw-r--r-- | demo/more/orm1.ur | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/demo/more/orm1.ur b/demo/more/orm1.ur new file mode 100644 index 00000000..bdf6ef8c --- /dev/null +++ b/demo/more/orm1.ur @@ -0,0 +1,38 @@ +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 () = + r <- T.create {A = 3, B = "Hi"}; + T.save (r -- #B ++ {B = "Bye"}); + + s <- S.create {C = r.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; + + return <xml><body> + {List.mapX (fn r => <xml><li> {[r.A]}: {[r.B]}</li></xml>) ls} + <br/> + {List.mapX (fn r => <xml><li> {[r.A]}: {[r.B]}</li></xml>) ls'} + <br/> + {List.mapX (fn (s, ro) => <xml><li> {[s.D]}: {case ro of + None => <xml>No parent</xml> + | Some r => <xml>{[r.B]}</xml>} + </li></xml>) lsS} + </body></xml> + +fun main () = return <xml><body> + <form><submit action={action}/></form> +</body></xml> |