diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-03-26 16:22:34 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-03-26 16:22:34 -0400 |
commit | c088dec7eff828276b3e9e8891b7cdc041e65430 (patch) | |
tree | 8ca09d90791aae6d8161cff1362f5c94480788f3 /tests/chat.ur | |
parent | b80bc0fde66898326c077f7a3aa47151d7f9e755 (diff) |
Preliminary work supporting channels in databases
Diffstat (limited to 'tests/chat.ur')
-rw-r--r-- | tests/chat.ur | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/chat.ur b/tests/chat.ur new file mode 100644 index 00000000..710d97d4 --- /dev/null +++ b/tests/chat.ur @@ -0,0 +1,36 @@ +sequence s +table t : { Id : int, Title : string, Chan : option (channel string) } + +fun list () = + queryX (SELECT * FROM t) + (fn r => <xml><tr> + <td>{[r.T.Id]}</td> <td>{[r.T.Title]}</td> + <td><a link={delete r.T.Id}>[delete]</a></td> + </tr></xml>) + +and delete id = + dml (DELETE FROM t WHERE Id = {[id]}); + main () + +and main () : transaction page = + let + fun create r = + id <- nextval s; + dml (INSERT INTO t (Id, Title, Chan) VALUES ({[id]}, {[r.Title]}, NULL)); + main () + in + ls <- list (); + return <xml><body> + <table> + <tr> <th>ID</th> <th>Title</th> </tr> + {ls} + </table> + + <h1>New Channel</h1> + + <form> + Title: <textbox{#Title}/><br/> + <submit action={create}/> + </form> + </body></xml> + end |