Migrates back to datomic on-prem
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
(ns auto-ap.datomic.accounts
|
||||
(:require
|
||||
[auto-ap.datomic
|
||||
:refer [add-sorter-fields apply-pagination apply-sort-3 conn merge-query conn pull-many]]
|
||||
:refer [add-sorter-fields
|
||||
apply-pagination
|
||||
apply-sort-3
|
||||
conn
|
||||
merge-query
|
||||
pull-many
|
||||
query2]]
|
||||
[clojure.string :as str]
|
||||
[datomic.client.api :as dc]
|
||||
[clojure.tools.logging :as log]))
|
||||
[clojure.tools.logging :as log]
|
||||
[datomic.api :as dc]))
|
||||
|
||||
(defn <-datomic [a]
|
||||
(-> a
|
||||
@@ -42,19 +48,19 @@
|
||||
:where [['?e :account/account-set '?account-set]]}
|
||||
:args [(:account-set args)]}))]
|
||||
(->>
|
||||
(dc/q query)
|
||||
(query2 query)
|
||||
(map first)
|
||||
(map <-datomic)))))
|
||||
|
||||
(defn get-by-id [id]
|
||||
(let [query {:query {:find [(list 'pull '?e default-read)]
|
||||
:in ['$ '?e]}
|
||||
:args [(dc/db conn ) id]}]
|
||||
(->>
|
||||
(dc/q query)
|
||||
(map first)
|
||||
(map <-datomic)
|
||||
first)))
|
||||
(->>
|
||||
(dc/q {:find [(list 'pull '?e default-read)]
|
||||
:in ['$ '?e]}
|
||||
(dc/db conn )
|
||||
id)
|
||||
(map first)
|
||||
(map <-datomic)
|
||||
first))
|
||||
|
||||
(defn get-for-vendor [vendor-id client-id]
|
||||
(if client-id
|
||||
@@ -87,15 +93,14 @@
|
||||
default-read))))
|
||||
|
||||
(defn get-account-by-numeric-code-and-sets [numeric-code _]
|
||||
(let [query (cond-> {:query {:find ['(pull ?e [* {:account/type [:db/ident :db/id]}])]
|
||||
:in ['$ '?numeric-code]
|
||||
:where ['[?e :account/numeric-code ?numeric-code]]}
|
||||
:args [(dc/db conn) numeric-code]})]
|
||||
(->>
|
||||
(dc/q query)
|
||||
(map first)
|
||||
(map <-datomic)
|
||||
(first))))
|
||||
(->>
|
||||
(dc/q {:find ['(pull ?e [* {:account/type [:db/ident :db/id]}])]
|
||||
:in ['$ '?numeric-code]
|
||||
:where ['[?e :account/numeric-code ?numeric-code]]}
|
||||
(dc/db conn) numeric-code)
|
||||
(map first)
|
||||
(map <-datomic)
|
||||
(first)))
|
||||
|
||||
(defn raw-graphql-ids [db args]
|
||||
(let [query (cond-> {:query {:find []
|
||||
@@ -122,8 +127,7 @@
|
||||
'[?e :account/numeric-code ?sort-default]]}}))]
|
||||
|
||||
|
||||
(cond->> query
|
||||
true (dc/q)
|
||||
(cond->> (query2 query)
|
||||
true (apply-sort-3 args)
|
||||
true (apply-pagination args))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user