babashka / babashka-sql-pods

Babashka pods for SQL databases
Eclipse Public License 1.0
85 stars 16 forks source link

support with-transaction #2

Closed borkdude closed 4 years ago

borkdude commented 4 years ago

We need something like described in https://github.com/babashka/babashka.pods/issues/4

Also functions dealing with connection "objects" need to return or receive some id by which the connection can be registered and managed by the pod.

The id is now represented by a map with an id in it (to distinguish from string db-specs).

In the future, when bb supports it, we could even make connection maps closeable by wrapping it in a defrecord client-side:

user=> (defrecord Foo [x] java.io.Closeable (close [this] (println "closing!")))
user.Foo
user=> (.close (->Foo 1))
closing!
nil
user=> (defmethod print-method Foo [v ^java.io.Writer w] (.write w (pr-str (into {} v))))
#object[clojure.lang.MultiFn 0x20a8a64e "clojure.lang.MultiFn@20a8a64e"]
user=> (pr-str (->Foo 1))
"{:x 1}"