aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/world/db/jdbc.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/library/lux/world/db/jdbc.lux78
1 files changed, 39 insertions, 39 deletions
diff --git a/stdlib/source/library/lux/world/db/jdbc.lux b/stdlib/source/library/lux/world/db/jdbc.lux
index 4fed0df0e..ccc9d91af 100644
--- a/stdlib/source/library/lux/world/db/jdbc.lux
+++ b/stdlib/source/library/lux/world/db/jdbc.lux
@@ -98,7 +98,7 @@
_ (io.io ((get@ #input statement) (get@ #value statement) [1 prepared]))
result (action prepared)
_ (java/sql/Statement::close prepared)]
- (wrap result)))
+ (in result)))
(def: #export (async db)
(-> (DB IO) (DB Async))
@@ -117,41 +117,41 @@
[connection (java/sql/DriverManager::getConnection (get@ #url creds)
(get@ #user creds)
(get@ #password creds))]
- (wrap (: (DB IO)
- (implementation
- (def: execute
- (..can-execute
- (function (execute statement)
- (with-statement statement connection
- (function (_ prepared)
- (do (try.with io.monad)
- [row-count (java/sql/PreparedStatement::executeUpdate prepared)]
- (wrap (.nat row-count))))))))
-
- (def: insert
- (..can-insert
- (function (insert statement)
- (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)))))))
-
- (def: close
- (..can-close
- (function (close _)
- (java/sql/Connection::close connection))))
-
- (def: query
- (..can-query
- (function (query [statement output])
- (with-statement statement connection
- (function (_ prepared)
- (do (try.with io.monad)
- [result-set (java/sql/PreparedStatement::executeQuery prepared)]
- (/output.rows output result-set)))))))
- )))))
+ (in (: (DB IO)
+ (implementation
+ (def: execute
+ (..can-execute
+ (function (execute statement)
+ (with-statement statement connection
+ (function (_ prepared)
+ (do (try.with io.monad)
+ [row-count (java/sql/PreparedStatement::executeUpdate prepared)]
+ (in (.nat row-count))))))))
+
+ (def: insert
+ (..can-insert
+ (function (insert statement)
+ (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)))))))
+
+ (def: close
+ (..can-close
+ (function (close _)
+ (java/sql/Connection::close connection))))
+
+ (def: query
+ (..can-query
+ (function (query [statement output])
+ (with-statement statement connection
+ (function (_ prepared)
+ (do (try.with io.monad)
+ [result-set (java/sql/PreparedStatement::executeQuery prepared)]
+ (/output.rows output result-set)))))))
+ )))))
(def: #export (with-db creds action)
(All [a]
@@ -162,7 +162,7 @@
[db (..connect creds)
result (action db)
_ (!.use (\ db close) [])]
- (wrap result)))
+ (in result)))
(def: #export (with-async-db creds action)
(All [a]
@@ -172,5 +172,5 @@
(do (try.with async.monad)
[db (async.future (..connect creds))
result (action (..async db))
- _ (async\wrap (io.run (!.use (\ db close) [])))]
- (wrap result)))
+ _ (async\in (io.run (!.use (\ db close) [])))]
+ (in result)))