mirror of
https://github.com/penpot/penpot.git
synced 2025-05-13 18:36:37 +02:00
✨ Improve with-atomic macro to accept cfg
This commit is contained in:
parent
d268ff2952
commit
27fb4c7ed9
3 changed files with 22 additions and 2 deletions
|
@ -6,7 +6,6 @@
|
||||||
rumext.v2/defc clojure.core/defn
|
rumext.v2/defc clojure.core/defn
|
||||||
rumext.v2/fnc clojure.core/fn
|
rumext.v2/fnc clojure.core/fn
|
||||||
app.common.data/export clojure.core/def
|
app.common.data/export clojure.core/def
|
||||||
app.db/with-atomic clojure.core/with-open
|
|
||||||
app.common.data.macros/get-in clojure.core/get-in
|
app.common.data.macros/get-in clojure.core/get-in
|
||||||
app.common.data.macros/with-open clojure.core/with-open
|
app.common.data.macros/with-open clojure.core/with-open
|
||||||
app.common.data.macros/select-keys clojure.core/select-keys
|
app.common.data.macros/select-keys clojure.core/select-keys
|
||||||
|
@ -18,6 +17,7 @@
|
||||||
potok.core/reify hooks.export/potok-reify
|
potok.core/reify hooks.export/potok-reify
|
||||||
app.util.services/defmethod hooks.export/service-defmethod
|
app.util.services/defmethod hooks.export/service-defmethod
|
||||||
app.common.record/defrecord hooks.export/penpot-defrecord
|
app.common.record/defrecord hooks.export/penpot-defrecord
|
||||||
|
app.db/with-atomic hooks.export/penpot-with-atomic
|
||||||
}}
|
}}
|
||||||
|
|
||||||
:output
|
:output
|
||||||
|
|
|
@ -39,6 +39,20 @@
|
||||||
other))]
|
other))]
|
||||||
{:node result})))
|
{:node result})))
|
||||||
|
|
||||||
|
(defn penpot-with-atomic
|
||||||
|
[{:keys [node]}]
|
||||||
|
(let [[_ params & other] (:children node)
|
||||||
|
|
||||||
|
result (if (api/vector-node? params)
|
||||||
|
(api/list-node
|
||||||
|
(into [(api/token-node (symbol "clojure.core" "with-open")) params] other))
|
||||||
|
(api/list-node
|
||||||
|
(into [(api/token-node (symbol "clojure.core" "with-open"))
|
||||||
|
(api/vector-node [params params])]
|
||||||
|
other)))
|
||||||
|
|
||||||
|
]
|
||||||
|
{:node result}))
|
||||||
|
|
||||||
(defn penpot-defrecord
|
(defn penpot-defrecord
|
||||||
[{:keys [:node]}]
|
[{:keys [:node]}]
|
||||||
|
|
|
@ -218,7 +218,13 @@
|
||||||
|
|
||||||
(defmacro with-atomic
|
(defmacro with-atomic
|
||||||
[& args]
|
[& args]
|
||||||
`(jdbc/with-transaction ~@args))
|
(if (symbol? (first args))
|
||||||
|
(let [cfgs (first args)
|
||||||
|
body (rest args)]
|
||||||
|
`(jdbc/with-transaction [conn# (::pool ~cfgs)]
|
||||||
|
(let [~cfgs (assoc ~cfgs ::conn conn#)]
|
||||||
|
~@body)))
|
||||||
|
`(jdbc/with-transaction ~@args)))
|
||||||
|
|
||||||
(defn open
|
(defn open
|
||||||
[pool]
|
[pool]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue