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 | dac2c194b1416d7710081d5c57c24d52e110a224 (patch) | |
tree | 8ca09d90791aae6d8161cff1362f5c94480788f3 /tests | |
parent | 024acc734f4a323883adb5e9a68f5f4f753e60cc (diff) |
Preliminary work supporting channels in databases
Diffstat (limited to 'tests')
-rw-r--r-- | tests/chat.ur | 36 | ||||
-rw-r--r-- | tests/chat.urp | 5 |
2 files changed, 41 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 diff --git a/tests/chat.urp b/tests/chat.urp new file mode 100644 index 00000000..1c42449d --- /dev/null +++ b/tests/chat.urp @@ -0,0 +1,5 @@ +debug +database dbname=chat +sql chat.sql + +chat |