diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/library/lux/world/db/jdbc.lux | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/stdlib/source/library/lux/world/db/jdbc.lux b/stdlib/source/library/lux/world/db/jdbc.lux index ccc9d91af..0d1112282 100644 --- a/stdlib/source/library/lux/world/db/jdbc.lux +++ b/stdlib/source/library/lux/world/db/jdbc.lux @@ -66,27 +66,27 @@ [(capability: #export (<name> ! i) (<forge> (Statement i) (! (Try <output>))))] - [Can-Execute can-execute Nat] - [Can-Insert can-insert (List ID)] + [Can_Execute can_execute Nat] + [Can_Insert can_insert (List ID)] ) -(capability: #export (Can-Query ! i o) - (can-query [(Statement i) (Output o)] (! (Try (List o))))) +(capability: #export (Can_Query ! i o) + (can_query [(Statement i) (Output o)] (! (Try (List o))))) -(capability: #export (Can-Close !) - (can-close Any (! (Try Any)))) +(capability: #export (Can_Close !) + (can_close Any (! (Try Any)))) (interface: #export (DB !) - (: (Can-Execute !) + (: (Can_Execute !) execute) - (: (Can-Insert !) + (: (Can_Insert !) insert) - (: (Can-Query !) + (: (Can_Query !) query) - (: (Can-Close !) + (: (Can_Close !) close)) -(def: (with-statement statement conn action) +(def: (with_statement statement conn action) (All [i a] (-> (Statement i) java/sql/Connection (-> java/sql/PreparedStatement (IO (Try a))) @@ -106,10 +106,10 @@ (~~ (template [<name> <forge>] [(def: <name> (<forge> (|>> (!.use (\ db <name>)) async.future)))] - [execute can-execute] - [insert can-insert] - [close can-close] - [query can-query]))))) + [execute can_execute] + [insert can_insert] + [close can_close] + [query can_query]))))) (def: #export (connect creds) (-> Credentials (IO (Try (DB IO)))) @@ -120,40 +120,40 @@ (in (: (DB IO) (implementation (def: execute - (..can-execute + (..can_execute (function (execute statement) - (with-statement statement connection + (with_statement statement connection (function (_ prepared) (do (try.with io.monad) - [row-count (java/sql/PreparedStatement::executeUpdate prepared)] - (in (.nat row-count)))))))) + [row_count (java/sql/PreparedStatement::executeUpdate prepared)] + (in (.nat row_count)))))))) (def: insert - (..can-insert + (..can_insert (function (insert statement) - (with-statement statement connection + (with_statement statement connection (function (_ prepared) (do (try.with io.monad) [_ (java/sql/PreparedStatement::executeUpdate prepared) - result-set (io.io (java/sql/Statement::getGeneratedKeys prepared))] - (/output.rows /output.long result-set))))))) + result_set (io.io (java/sql/Statement::getGeneratedKeys prepared))] + (/output.rows /output.long result_set))))))) (def: close - (..can-close + (..can_close (function (close _) (java/sql/Connection::close connection)))) (def: query - (..can-query + (..can_query (function (query [statement output]) - (with-statement statement connection + (with_statement statement connection (function (_ prepared) (do (try.with io.monad) - [result-set (java/sql/PreparedStatement::executeQuery prepared)] - (/output.rows output result-set))))))) + [result_set (java/sql/PreparedStatement::executeQuery prepared)] + (/output.rows output result_set))))))) ))))) -(def: #export (with-db creds action) +(def: #export (with_db creds action) (All [a] (-> Credentials (-> (DB IO) (IO (Try a))) @@ -164,7 +164,7 @@ _ (!.use (\ db close) [])] (in result))) -(def: #export (with-async-db creds action) +(def: #export (with_async_db creds action) (All [a] (-> Credentials (-> (DB Async) (Async (Try a))) |