(ns auto-ap.datomic.vendors
  (:require [datomic.api :as d]
            [auto-ap.datomic :refer [uri]]))

(defn get-graphql [args]
  (prn (->> (d/q '[:find (pull ?e [*])
                   :where [?e :vendor/name]]
                 (d/db (d/connect uri)))
            (map first)
            (take 5)))
  
       (->> (d/q '[:find (pull ?e [*])
                   :where [?e :vendor/name]]
                 (d/db (d/connect uri)))
       (map first)
       
       #_(map (fn [c]
                (update c :client/bank-accounts
                        (fn [bas]
                          (map (fn [ba]
                                 (update ba :bank-account/type :db/ident ))
                               bas)))))))

(defn get-by-id [id]
  
  (->> (d/q '[:find (pull ?e [*])
              :in $ ?e
              :where [?e]]
            (d/db (d/connect uri))
            id)
       (map first)
       (first)
       #_(map (fn [c]
                (update c :client/bank-accounts
                        (fn [bas]
                          (map (fn [ba]
                                 (update ba :bank-account/type :db/ident ))
                               bas)))))))
