progress on making saving work better for accounts.
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
(:require [datomic.api :as d]
|
||||
[auto-ap.datomic.accounts :as d-accounts]
|
||||
[auto-ap.graphql.utils :refer [->graphql <-graphql enum->keyword] ]
|
||||
[auto-ap.datomic :refer [uri merge-query remove-nils]]))
|
||||
[auto-ap.datomic :refer [uri merge-query remove-nils audit-transact]]
|
||||
[clojure.tools.logging :as log]))
|
||||
|
||||
|
||||
|
||||
@@ -22,8 +23,7 @@
|
||||
{} ))))
|
||||
|
||||
(let [original (if id (d/entity (d/db (d/connect uri)) id))
|
||||
result @(d/transact (d/connect uri)
|
||||
(cond->
|
||||
result (audit-transact (cond->
|
||||
[(remove-nils
|
||||
{:db/id (or id "new-account")
|
||||
:account/name name
|
||||
@@ -39,10 +39,12 @@
|
||||
(mapv
|
||||
(fn [client-override]
|
||||
(remove-nils
|
||||
{:account-client-override/client (:client-id client-override)
|
||||
{:db/id (:id client-override)
|
||||
:account-client-override/client (:client-id client-override)
|
||||
:account-client-override/name (:name client-override)}))
|
||||
client-overrides)]]
|
||||
(and (not location) (:account/location original)) (conj [:db/retract (or id "new-account") :account/location (:account/location original)])))]
|
||||
(and (not location) (:account/location original)) (conj [:db/retract (or id "new-account") :account/location (:account/location original)]))
|
||||
(:id context))]
|
||||
(->graphql
|
||||
(d-accounts/get-by-id (or id (get-in result [:tempids "new-account"])))))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user