<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Datomic Knowledgebase - Recent questions and answers in Client API</title>
<link>https://ask.datomic.com/index.php/qa/client-api</link>
<description>Powered by Question2Answer</description>
<item>
<title>Answered: Pulling :db/id will pull the entire entity</title>
<link>https://ask.datomic.com/index.php/703/pulling-db-id-will-pull-the-entire-entity?show=936#a936</link>
<description>&lt;p&gt;This bug boxes me in a corner ... I don't know the &quot;type&quot; of the entity whose &lt;code&gt;:db/id&lt;/code&gt; I'm trying to pull, so I can't add an addtional attribute to work around the problem.  And just using &lt;code&gt;[*]&lt;/code&gt; has the big liability noted in the report above.&lt;/p&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/703/pulling-db-id-will-pull-the-entire-entity?show=936#a936</guid>
<pubDate>Fri, 14 Jul 2023 15:53:05 +0000</pubDate>
</item>
<item>
<title>Answered: Duplicate var in :find and :with throws ArrayIndexOutOfBoundsException</title>
<link>https://ask.datomic.com/index.php/724/duplicate-find-with-throws-arrayindexoutofboundsexception?show=928#a928</link>
<description>&lt;p&gt;(Not an answer, but another example of the scope of this bug.)&lt;/p&gt;
&lt;p&gt;I think the same underlying error can be provoked when using &lt;code&gt;pull&lt;/code&gt; and not using &lt;code&gt;with&lt;/code&gt;.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;(d/q {:query '[:find ?c (pull ?c [*])&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;                   :where 
                   , [?c :ansi.fips/state-numeric &quot;51&quot;]
                   , [?c :usps/state-name ?sn]]
          :args [db]})
&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;That ^ provokes the &lt;code&gt;IndexOutOfBoundsException&lt;/code&gt; but it can be resolved by removing either the pull or the bare &lt;code&gt;?c&lt;/code&gt; from the find expression.  This &lt;em&gt;is&lt;/em&gt; frustrating for automated query construction.&lt;/p&gt;
&lt;p&gt;(And I've given up trying to get the code sample to format correctly... the embedded quote in the code wreaks havoc with this site's formatter....)&lt;/p&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/724/duplicate-find-with-throws-arrayindexoutofboundsexception?show=928#a928</guid>
<pubDate>Sun, 28 May 2023 21:30:11 +0000</pubDate>
</item>
<item>
<title>Answered: Error connecting to datomic cloud</title>
<link>https://ask.datomic.com/index.php/861/error-connecting-to-datomic-cloud?show=864#a864</link>
<description>&lt;p&gt;This error indicates that you do not have the sourced AWS credentials to connect to the AWS account you are running Cloud in.&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://docs.datomic.com/cloud/operation/access-control.html#how-datomic-access-control-works&quot;&gt;https://docs.datomic.com/cloud/operation/access-control.html#how-datomic-access-control-works&lt;/a&gt;&lt;/p&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/861/error-connecting-to-datomic-cloud?show=864#a864</guid>
<pubDate>Mon, 19 Dec 2022 14:02:51 +0000</pubDate>
</item>
<item>
<title>java.lang.IllegalArgumentException: Cannot resolve key: 24a96e20-f526-4f7f-ba38-4f684caa5607</title>
<link>https://ask.datomic.com/index.php/720/illegalargumentexception-resolve-24a96e20-4f684caa5607</link>
<description>&lt;p&gt;I am trying to implement resursive rule (loglcal OR) by following this video - Lucas Cavalcanti &amp;amp; Edward Wible - Exploring four hidden superpowers of Datomic&lt;/p&gt;
&lt;p&gt;Here the code&lt;/p&gt;
&lt;p&gt;(defn owns? [cid pid db]&lt;br&gt;
  (d/q '{:find [?pur]&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;     :in [$ ?cus-id ?pur %]
     :where
     [(owns? ?cus-id ?pur)]}
db cid [:purchase/id pid] owner-rules))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(comment&lt;br&gt;
  (owns?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#uuid &quot;0fb7ea94-44af-46fa-98ca-0ddb5eb23123&quot;
#uuid &quot;24a96e20-f526-4f7f-ba38-4f684caa5607&quot;
(d/db bank-conn)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;While running the above example I am getting this error: &lt;br&gt;
java.lang.IllegalArgumentException Cannot resolve key: 24a96e20-f526-4f7f-ba38-4f684caa5607&lt;/p&gt;
&lt;p&gt;Here is the full code:&lt;/p&gt;
&lt;p&gt;(def purchase-schema&lt;br&gt;
  [{:db/ident :purchase/id&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;:db/doc &quot;The purchase ID&quot;
:db/unique :db.unique/identity
:db/valueType :db.type/uuid
:db/cardinality :db.cardinality/one}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;   {:db/ident :purchase/account&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;:db/doc &quot;Purchase Account&quot;
:db/valueType :db.type/ref
:db/cardinality :db.cardinality/one}])
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(def account-schema&lt;br&gt;
  [{:db/ident :account/id&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;:db/doc &quot;The Account ID&quot;
:db/unique :db.unique/identity
:db/valueType :db.type/uuid
:db/cardinality :db.cardinality/one}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;   {:db/ident :account/customer&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;:db/doc &quot;Customer who own's this account&quot;
:db/valueType :db.type/ref
:db/cardinality :db.cardinality/one}])
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(def customer-schema&lt;br&gt;
  [{:db/ident :customer/id&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;:db/doc &quot;Customer ID&quot;
:db/unique :db.unique/identity
:db/valueType :db.type/uuid
:db/cardinality :db.cardinality/one}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;   {:db/ident :customer/name&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;:db/doc &quot;Customer name&quot;
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one}])
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;;;&lt;br&gt;
;; Create client&lt;br&gt;
(def client (d/client {:server-type :dev-local&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;                   :system &quot;dev&quot;}))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;;; Create connections&lt;br&gt;
(def bank-conn    (d/connect client {:db-name &quot;bank&quot;}))&lt;/p&gt;
&lt;p&gt;;; Transact schemas&lt;br&gt;
(comment&lt;br&gt;
  (d/transact  bank-conn {:tx-data purchase-schema})&lt;br&gt;
  (d/transact  bank-conn {:tx-data account-schema})&lt;br&gt;
  (d/transact  bank-conn {:tx-data customer-schema})&lt;br&gt;
  (d/tx-range  bank-conn {:start 6}))&lt;/p&gt;
&lt;p&gt;(comment&lt;br&gt;
  (java.util.UUID/randomUUID))&lt;/p&gt;
&lt;p&gt;;; Transact fake data&lt;br&gt;
(def cid #uuid &quot;0fb7ea94-44af-46fa-98ca-0ddb5eb23123&quot;)&lt;br&gt;
(def sample-customer {:customer/id cid&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;                  :customer/name &quot;Jon Snow&quot;})
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(def aid #uuid &quot;c579a9f6-f6c3-4718-8ecf-c3003021ee9a&quot;)&lt;br&gt;
(def sample-account {:account/id aid&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;                 :account/customer [:customer/id cid]})
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(def pid #uuid &quot;24a96e20-f526-4f7f-ba38-4f684caa5607&quot;)&lt;br&gt;
(def sample-purchase {:purchase/id  pid&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;                  :purchase/account [:account/id aid]})
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(comment&lt;br&gt;
  (d/transact bank-conn {:tx-data [sample-customer]})&lt;br&gt;
  (d/transact bank-conn {:tx-data [sample-account]})&lt;br&gt;
  (d/transact bank-conn {:tx-data [sample-purchase]}))&lt;/p&gt;
&lt;p&gt;(comment&lt;br&gt;
  (d/q '[:find ?cus&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;     :in $ ?cid ?pid
     :where
     [?pur :purchase/id ?pid]
     [?pur :purchase/account ?acc]
     [?acc :account/customer ?cus]
     [?cus :customer/id ?cid]]
  (d/db bank-conn)
  (:customer/id sample-customer)
  (:purchase/id sample-purchase)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;;; owns v1&lt;br&gt;
(defn ownsv1? [cid pid db]&lt;br&gt;
  (d/q '[:find ?cus&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;     :in $ ?customer-id ?purchase-id
     :where
     [?pur :purchase/id ?purchase-id]
     [?pur :purchase/account ?acc]
     [?acc :account/customer ?cus]
     [?cus :customer/id ?customer-id]]
db cid pid))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(comment&lt;br&gt;
  (ownsv1?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(:customer/id sample-customer)
(:purchase/id sample-purchase)
(d/db bank-conn)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;;; recursive rule (logical OR)&lt;br&gt;
(def owner-rules&lt;br&gt;
  '[[(owns? ?cus-id ?e)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; [?e :customer/id ?cus-id]]
[(owns? ?cus-id ?e)
 [?e ?ref-attr ?r]
 (owns? ?cus-id ?r)]])
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(defn owns? [cid pid db]&lt;br&gt;
  (d/q '{:find [?pur]&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;     :in [$ ?cus-id ?pur %]
     :where
     [(owns? ?cus-id ?pur)]}
db cid [:purchase/id pid] owner-rules))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;;;&lt;br&gt;
(comment&lt;br&gt;
  (owns?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(:customer/id sample-customer)
(:purchase/id sample-purchase)
(d/db bank-conn)))
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/720/illegalargumentexception-resolve-24a96e20-4f684caa5607</guid>
<pubDate>Mon, 06 Jun 2022 19:37:30 +0000</pubDate>
</item>
<item>
<title>client api: clear cache when credentials change</title>
<link>https://ask.datomic.com/index.php/689/client-api-clear-cache-when-credentials-change</link>
<description>&lt;p&gt;I have my development program running and connect to datomic proper. How do I clear the caches because it brakes when I need new aws creds.&lt;/p&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/689/client-api-clear-cache-when-credentials-change</guid>
<pubDate>Tue, 14 Dec 2021 08:30:00 +0000</pubDate>
</item>
<item>
<title>Answered: Pull identical var in two :find positions</title>
<link>https://ask.datomic.com/index.php/682/pull-identical-var-in-two-find-positions?show=684#a684</link>
<description>&lt;p&gt;Hi thank you for the detailed reproduction and problem statement.  Each variable can appear in at most one pull expression.  This behavior was not documented, but I've now added this to our docs on pull expressions in cloud and on-prem:&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://docs.datomic.com/cloud/query/query-data-reference.html#pull-expressions&quot;&gt;https://docs.datomic.com/cloud/query/query-data-reference.html#pull-expressions&lt;/a&gt;&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://docs.datomic.com/on-prem/query/query.html#pull-expressions&quot;&gt;https://docs.datomic.com/on-prem/query/query.html#pull-expressions&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br&gt;
Jaret&lt;/p&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/682/pull-identical-var-in-two-find-positions?show=684#a684</guid>
<pubDate>Tue, 16 Nov 2021 16:03:15 +0000</pubDate>
</item>
<item>
<title>How to install transaction function using the [com.datomic/client-pro &quot;0.9.63&quot;]</title>
<link>https://ask.datomic.com/index.php/673/how-install-transaction-function-using-the-datomic-client</link>
<description>&lt;p&gt;How to install transaction function using the [com.datomic/client-pro &quot;0.9.63&quot;] ?&lt;br&gt;
I am following this example &lt;a rel=&quot;nofollow&quot; href=&quot;https://docs.datomic.com/on-prem/reference/database-functions.html&quot;&gt;https://docs.datomic.com/on-prem/reference/database-functions.html&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;However there is no d/function to install the transaction function... And looking at the documentation there is only datomic dev local and datomic client pro libraries&lt;/p&gt;
&lt;p&gt;How can I create a transaction function using the client pro lib?&lt;/p&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/673/how-install-transaction-function-using-the-datomic-client</guid>
<pubDate>Wed, 13 Oct 2021 16:27:12 +0000</pubDate>
</item>
<item>
<title>How to integrate library using datomic.client.api when using the peer library?</title>
<link>https://ask.datomic.com/index.php/663/integrate-library-using-datomic-client-when-using-library</link>
<description>&lt;p&gt;I am using the peer library for on-prem Datomic. Now I want to use a library - ragtime.datomic - that uses the datomic.client.api. How can I do that?&lt;/p&gt;
&lt;p&gt;Based on &lt;a rel=&quot;nofollow&quot; href=&quot;https://docs.datomic.com/client-api/datomic.client.api.html#var-client&quot;&gt;https://docs.datomic.com/client-api/datomic.client.api.html#var-client&lt;/a&gt; it seems the only option is to run a separate peer process, exposed at a port and set up authorization between the two. But it seems wasteful to run a separate server when I already have the peer library. Is there a simpler way?&lt;/p&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/663/integrate-library-using-datomic-client-when-using-library</guid>
<pubDate>Fri, 03 Sep 2021 17:33:57 +0000</pubDate>
</item>
<item>
<title>Answered: `Unable to read keyfile` error when trying to initialize Datomic Cloud with Client API</title>
<link>https://ask.datomic.com/index.php/653/unable-keyfile-error-trying-initialize-datomic-cloud-client?show=654#a654</link>
<description>&lt;p&gt;Hi Julia, &lt;/p&gt;
&lt;p&gt;That looks like your REPL in intelliJ is missing aws credentials.  These can be set by editing your REPL configuration in intelliJ and setting the environment credentials for AWS_SECRET_KEY etc:&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;http://imgur.com/a/P4tdshR&quot;&gt;http://imgur.com/a/P4tdshR&lt;/a&gt;&lt;br&gt;
&lt;img src=&quot;http://imgur.com/a/P4tdshR&quot; alt=&quot;IntelliJ Creds&quot;&gt;&lt;/p&gt;
&lt;p&gt;You can also provide a named profile if you have AWS profiles configured. &lt;a rel=&quot;nofollow&quot; href=&quot;https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html&quot;&gt;https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html&lt;/a&gt;.  You can use these profiles in your connection (&lt;a rel=&quot;nofollow&quot; href=&quot;https://docs.datomic.com/cloud/tutorial/client.html#using-datomic-cloud&quot;&gt;https://docs.datomic.com/cloud/tutorial/client.html#using-datomic-cloud&lt;/a&gt;) to a Datomic Cloud system, but if you are connecting locally from your laptop your REPL will also need sourced credentials that can access the AWS resources.&lt;/p&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/653/unable-keyfile-error-trying-initialize-datomic-cloud-client?show=654#a654</guid>
<pubDate>Wed, 25 Aug 2021 13:38:05 +0000</pubDate>
</item>
<item>
<title>Answered: Should you cache d/connect calls?</title>
<link>https://ask.datomic.com/index.php/569/should-you-cache-d-connect-calls?show=628#a628</link>
<description>&lt;p&gt;At least more time on doing actions which require  datomic connection. More DB data more time connection&lt;/p&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/569/should-you-cache-d-connect-calls?show=628#a628</guid>
<pubDate>Fri, 18 Jun 2021 15:03:10 +0000</pubDate>
</item>
<item>
<title>Answered: Recommended way to handle :db/ident enums when used with d/pull?</title>
<link>https://ask.datomic.com/index.php/606/recommended-way-to-handle-db-ident-enums-when-used-with-pull?show=624#a624</link>
<description>&lt;p&gt;This is the helper I'm using, I'm sure it performs better than the one you referred.  Also, it doesn't require you to explicitly pull :db/ident fields and it works on pull-many and pull results.  Consider replacing &lt;code&gt;map&lt;/code&gt; with &lt;code&gt;mapv&lt;/code&gt; if you want to retain vectors instead of lazy seqs.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn resolve-idents
  &quot;Helper that resolves all idents in a pull expression return to
  their :db/ident keyword.&quot;
  [db x]
  (cond (map? x)
        (if-let [ident (d/ident db (:db/id x))]
          ident
          (reduce-kv (fn [x k v]
                       (assoc x k (resolve-idents db v)))
                     x x))
        (vector? x)
        (map #(resolve-idents db %) x)
        :else
        x))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Regarding the question how to deal with this:&lt;/p&gt;
&lt;p&gt;Use a helper like this and wrap it in your own version of pull/pull-many:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn full 
  &quot;Version of pull that resolves idents&quot;
  [db expr id]
  (-&amp;gt;&amp;gt; (d/pull db expr id) (resolve-idents db)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Regarding this topic in general:&lt;/p&gt;
&lt;p&gt;I'd really be interested in Cognitects reasons to implement this behavior differently from the good old entity API.  There are obviously some pros and cons, but it would be interesting to know the decisive reasons.&lt;/p&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/606/recommended-way-to-handle-db-ident-enums-when-used-with-pull?show=624#a624</guid>
<pubDate>Tue, 08 Jun 2021 10:38:29 +0000</pubDate>
</item>
<item>
<title>Answered: How to gracefully handle optional query inputs?</title>
<link>https://ask.datomic.com/index.php/616/how-to-gracefully-handle-optional-query-inputs?show=621#a621</link>
<description>&lt;p&gt;Instead of doing it 'in' the query,  use clojure's data manip to create the query you want.  &lt;/p&gt;
&lt;p&gt;This is where queries themselves being data is really cool. The map form may be more useful in this context.  Here's a quick and dirty...  Added assumed :product/id to make it clearer.  IRL, you'd want to make sure more selective clauses are first, etc etc.  If you have complex combos, you might want to look at something like meander&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn product-q
    [name]
    (cond-&amp;gt; '{:find [?p]
              :in [$]
              :where [[?p :product/id _]]}
      name (-&amp;gt; (update :in conj '?name)
             (update :where conj '[?p :product/name ?name]))))

(product-q nil)
=&amp;gt; {:find [?p]
    :in [$]
    :where [[?p :product/id _]]}
    
(product-q &quot;cheetos&quot;)
=&amp;gt; {:find [?p]
    :in [$ ?name]
    :where [[?p :product/id _]
            [?p :product/name ?name]]
 
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/616/how-to-gracefully-handle-optional-query-inputs?show=621#a621</guid>
<pubDate>Tue, 01 Jun 2021 19:12:29 +0000</pubDate>
</item>
<item>
<title>Additional keys on anomaly part of the API?</title>
<link>https://ask.datomic.com/index.php/608/additional-keys-on-anomaly-part-of-the-api</link>
<description>&lt;p&gt;Datomic sometimes attaches additional keys onto the anomaly in ex-data on the &lt;code&gt;ExceptionInfo&lt;/code&gt;s thrown. Is this additional data part of the API and able to be depended on? Further, could all keys returned be documented in the &lt;a rel=&quot;nofollow&quot; href=&quot;https://docs.datomic.com/client-api/datomic.client.api.html&quot;&gt;api docs&lt;/a&gt;? The returned keys are typically quite helpful in dispatching on different Datomic error &quot;types.&quot;&lt;/p&gt;
&lt;p&gt;Here's an example.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(def client (d/client {:server-type :dev-local
                       :storage-dir :mem
                       :system      &quot;aa&quot;}))
=&amp;gt; #'compute.http-api.public.task/client
(d/create-database client {:db-name &quot;test&quot;})
=&amp;gt; true
(def conn (d/connect client {:db-name &quot;test&quot;}))
=&amp;gt; #'compute.http-api.public.task/conn
(d/transact conn {:tx-data [{:db/ident       :user/id
                             :db/cardinality :db.cardinality/one
                             :db/valueType   :db.type/string
                             :db/unique      :db.unique/identity}
                            {:db/ident       :user/name
                             :db/cardinality :db.cardinality/one
                             :db/valueType   :db.type/string
                             :db/unique      :db.unique/identity}]})
=&amp;gt;
{:db-before #datomic.core.db.Db{:id &quot;47c8f6f7-26f9-4575-97ec-7fc0948823c1&quot;,
                                :basisT 5,
                                :indexBasisT 0,
                                :index-root-id nil,
                                :asOfT nil,
                                :sinceT nil,
                                :raw nil},
 :db-after #datomic.core.db.Db{:id &quot;47c8f6f7-26f9-4575-97ec-7fc0948823c1&quot;,
                               :basisT 6,
                               :indexBasisT 0,
                               :index-root-id nil,
                               :asOfT nil,
                               :sinceT nil,
                               :raw nil},
 :tx-data [#datom[13194139533318 50 #inst&quot;2021-05-09T01:32:25.677-00:00&quot; 13194139533318 true]
           #datom[73 10 :user/id 13194139533318 true]
           #datom[73 41 35 13194139533318 true]
           #datom[73 40 23 13194139533318 true]
           #datom[73 42 38 13194139533318 true]
           #datom[74 10 :user/name 13194139533318 true]
           #datom[74 41 35 13194139533318 true]
           #datom[74 40 23 13194139533318 true]
           #datom[74 42 38 13194139533318 true]
           #datom[0 13 73 13194139533318 true]
           #datom[0 13 74 13194139533318 true]],
 :tempids {}}
(d/transact conn {:tx-data [{:db/id     [:user/id &quot;a&quot;]
                             :user/name &quot;a&quot;}]})
Execution error (ExceptionInfo) at datomic.core.error/raise (error.clj:55).
:db.error/not-an-entity Unable to resolve entity: [:user/id &quot;a&quot;] in datom [[:user/id &quot;a&quot;] :user/name &quot;a&quot;]
(ex-data *e)
=&amp;gt;
{:cognitect.anomalies/category :cognitect.anomalies/incorrect,
 :cognitect.anomalies/message &quot;Unable to resolve entity: [:user/id \&quot;a\&quot;] in datom [[:user/id \&quot;a\&quot;] :user/name \&quot;a\&quot;]&quot;,
 :entity [:user/id &quot;a&quot;],
 :datom [[:user/id &quot;a&quot;] :user/name &quot;a&quot;],
 :db/error :db.error/not-an-entity}
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/608/additional-keys-on-anomaly-part-of-the-api</guid>
<pubDate>Sun, 09 May 2021 01:33:17 +0000</pubDate>
</item>
<item>
<title>Answered: When would I want to use :server-type :cloud?</title>
<link>https://ask.datomic.com/index.php/590/when-would-i-want-to-use-server-type-cloud?show=596#a596</link>
<description>&lt;p&gt;A &lt;code&gt;:cloud&lt;/code&gt; connection uses endpoint etc. to make a client-server connection.&lt;/p&gt;
&lt;p&gt;An &lt;code&gt;:ion&lt;/code&gt; connection takes the same arguments, but will ignore them if the code is running on a Cloud node, creating a client implementation that runs entirely in-memory on the current node.&lt;/p&gt;
&lt;p&gt;You could use &lt;code&gt;:cloud&lt;/code&gt; to force one Datomic Cloud system to connect to a different system.&lt;/p&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/590/when-would-i-want-to-use-server-type-cloud?show=596#a596</guid>
<pubDate>Fri, 26 Feb 2021 15:23:17 +0000</pubDate>
</item>
<item>
<title>Answered: Usage of datomic client API's with in order to simulate facts without asserting.</title>
<link>https://ask.datomic.com/index.php/499/usage-datomic-client-order-simulate-facts-without-asserting?show=587#a587</link>
<description>&lt;p&gt;According to the documentation, it looks like the &lt;code&gt;d/with&lt;/code&gt; fn requires a DB value that comes from the &lt;code&gt;d/with-db&lt;/code&gt; fn.  So try:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(d/q '[:find (count ?e1)                             
   :in $                                                                                                                                         
   :where [?e1 :token/color :grey]]                                                                                                 
 (d/with (d/with-db conn) {:tx-data [{:token/color :grey}]}))
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/499/usage-datomic-client-order-simulate-facts-without-asserting?show=587#a587</guid>
<pubDate>Thu, 04 Feb 2021 22:13:12 +0000</pubDate>
</item>
<item>
<title>Add default :timeout to client api ns docstring</title>
<link>https://ask.datomic.com/index.php/563/add-default-timeout-to-client-api-ns-docstring</link>
<description>&lt;p&gt;It'd be great to have the default value for &lt;code&gt;:timeout&lt;/code&gt; (60000) included in the &lt;code&gt;datomic.client.api&lt;/code&gt; ns docstring. Currently this value can only be found in the &lt;a rel=&quot;nofollow&quot; href=&quot;https://docs.datomic.com/cloud/client/client-api.html#timeouts&quot;&gt;docs on the website&lt;/a&gt;. As of client-cloud 0.8.102, the ns docstring specifies the default value for &lt;code&gt;:limit&lt;/code&gt;. &lt;/p&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/563/add-default-timeout-to-client-api-ns-docstring</guid>
<pubDate>Thu, 24 Dec 2020 00:12:44 +0000</pubDate>
</item>
<item>
<title>Datomic Client API equivalent to on-prem tx-&gt;t, t-&gt;tx</title>
<link>https://ask.datomic.com/index.php/562/datomic-client-api-equivalent-to-on-prem-tx-t-t-tx</link>
<description>&lt;p&gt;The Datomic client API does not provider &lt;code&gt;tx-&amp;gt;t&lt;/code&gt; or &lt;code&gt;t-&amp;gt;tx&lt;/code&gt;. These functions can be useful for very specific scenarios (e.g., you have a tx id and want to know if the database has &quot;moved forward&quot;). &lt;/p&gt;
&lt;p&gt;This was also requested on &lt;a rel=&quot;nofollow&quot; href=&quot;https://forum.datomic.com/t/datomic-client-api-equivalent-to-on-prem-tx-t/851&quot;&gt;the forums&lt;/a&gt;. A workaround was provided for the user's specific case but the request is still relevant. &lt;/p&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/562/datomic-client-api-equivalent-to-on-prem-tx-t-t-tx</guid>
<pubDate>Mon, 21 Dec 2020 00:25:17 +0000</pubDate>
</item>
<item>
<title>Answered: What approach do you use to detect a good connection to avoid :cognitect.anomalies/unavailable exceptions?</title>
<link>https://ask.datomic.com/index.php/486/approach-connection-cognitect-anomalies-unavailable-exceptions?show=492#a492</link>
<description>&lt;p&gt;We use something very similar to the below code. Most of the code originates from &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/cognitect-labs/aws-api/blob/master/src/cognitect/aws/retry.clj&quot;&gt;aws-api&lt;/a&gt;. The retry code is generic and can be used for all sorts of stuff.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Where&lt;/em&gt; you want to retry is often use-case dependent. Something to keep in mind. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn with-retry-sync
  &quot;Calls work-fn until retriable? is false or backoff returns nil. If work-fn
  throws, the exception will be passed to retriable?. If it is not retriable, the
  exception will be thrown. work-fn is a function of no arguments. retriable? is
  passed the result or exception from calling work-fn. backoff is a function of
  the number of times work-fn has been called.&quot;
  [work-fn retriable? backoff]
  (let [maybe-throw #(if (instance? Throwable %) (throw %) %)]
    (loop [retries 0]
      (let [resp (try (work-fn) (catch Throwable t t))]
        (if (retriable? resp)
          (if-let [bo (backoff retries)]
            (do
              (Thread/sleep bo)
              (recur (inc retries)))
            (maybe-throw resp))
          (maybe-throw resp))))))

(defn capped-exponential-backoff
  &quot;Returns a function of the num-retries (so far), which returns the
  lesser of max-backoff and an exponentially increasing multiple of
  base, or nil when (&amp;gt;= num-retries max-retries).
  See with-retry to see how it is used.
  Alpha. Subject to change.&quot;
  ([] (capped-exponential-backoff 100 10000 8))
  ([base max-backoff max-retries]
   (fn [num-retries]
     (when (&amp;lt; num-retries max-retries)
       (min max-backoff
         (* base (bit-shift-left 1 num-retries)))))))

(defn capped-exponential-backoff-with-jitter
  ([] (capped-exponential-backoff-with-jitter {}))
  ([{:keys [base
            max-backoff
            max-retries
            max-jitter-ms]
     :or   {base          100
            max-backoff   20000
            max-retries   4
            max-jitter-ms 100}}]
   (let [backoff-fn (capped-exponential-backoff
                      base
                      max-backoff
                      max-retries)]
     (fn [num-retries]
       (when-let [backoff-ms (backoff-fn num-retries)]
         ;; adding &quot;jitter&quot; can help reduce throttling on retries:
         ;; https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
         (min (+ backoff-ms (rand-int max-jitter-ms)) max-backoff))))))

(defn default-retriable?
  &quot;Returns true if x is an anomaly or if it is an ExceptionInfo with an anomaly
  in its ex-data.&quot;
  [x]
  (or
    (contains? #{:cognitect.anomalies/busy
                 :cognitect.anomalies/unavailable}
      (:cognitect.anomalies/category x))
    (and (instance? clojure.lang.ExceptionInfo x)
      (default-retriable? (ex-data x)))))

(defn connect
  [client arg-map]
  (with-retry-sync #(d/connect client arg-map)
    default-retriable? (capped-exponential-backoff-with-jitter)))
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/486/approach-connection-cognitect-anomalies-unavailable-exceptions?show=492#a492</guid>
<pubDate>Thu, 29 Oct 2020 00:52:24 +0000</pubDate>
</item>
<item>
<title>Client library for Python</title>
<link>https://ask.datomic.com/index.php/425/client-library-for-python</link>
<description>&lt;p&gt;Provide client implementation in Python&lt;/p&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/425/client-library-for-python</guid>
<pubDate>Thu, 22 Oct 2020 16:45:51 +0000</pubDate>
</item>
<item>
<title>Client API: tx-report-queue equivalent</title>
<link>https://ask.datomic.com/index.php/424/client-api-tx-report-queue-equivalent</link>
<description>&lt;p&gt;One of the features I miss a lot in the client API is TX report queues. Would it be possible to add something like this to the client? Perhaps tx-range could get an option that, when no :end is given, keeps the channel open and waits for future transactions?&lt;/p&gt;
</description>
<category>Client API</category>
<guid isPermaLink="true">https://ask.datomic.com/index.php/424/client-api-tx-report-queue-equivalent</guid>
<pubDate>Thu, 22 Oct 2020 16:25:01 +0000</pubDate>
</item>
</channel>
</rss>