32 lines
953 B
Clojure
32 lines
953 B
Clojure
(ns auto-ap.datomic.clients
|
|
(:require [datomic.api :as d]
|
|
[auto-ap.datomic :refer [uri]]))
|
|
|
|
(defn get-all []
|
|
|
|
(->> (d/q '[:find (pull ?e [* {:client/address [*]}])
|
|
:where [?e :client/name]]
|
|
(d/db (d/connect uri)))
|
|
(map first)
|
|
(map (fn [c]
|
|
(update c :client/bank-accounts
|
|
(fn [bas]
|
|
(map (fn [i ba]
|
|
(-> ba
|
|
(update :bank-account/type :db/ident )
|
|
(update :bank-account/sort-order (fn [so] (or so i)))))
|
|
(range) bas)))))
|
|
))
|
|
(defn get-by-id [id]
|
|
(->>
|
|
(d/query (-> {:query {:find ['(pull ?e [*])]
|
|
:in ['$ '?e]
|
|
:where [['?e]]}
|
|
:args [(d/db (d/connect uri)) id]}
|
|
))
|
|
(first)
|
|
(first)
|
|
#_(map first)
|
|
|
|
#_(first)))
|