This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-05
Channels
- # announcements (7)
- # babashka (20)
- # beginners (130)
- # bristol-clojurians (1)
- # cider (14)
- # clj-kondo (7)
- # cljdoc (14)
- # cljs-dev (15)
- # cljsrn (16)
- # clojars (11)
- # clojure (190)
- # clojure-dev (4)
- # clojure-europe (7)
- # clojure-italy (9)
- # clojure-nl (3)
- # clojure-romania (6)
- # clojure-uk (51)
- # clojurescript (44)
- # component (4)
- # conjure (28)
- # cursive (1)
- # data-science (4)
- # datascript (1)
- # datomic (30)
- # duct (4)
- # emacs (1)
- # figwheel (4)
- # fulcro (56)
- # graalvm (4)
- # helix (51)
- # jackdaw (2)
- # jobs-discuss (12)
- # joker (4)
- # lambdaisland (1)
- # local-first-clojure (1)
- # meander (73)
- # mid-cities-meetup (2)
- # nrepl (4)
- # off-topic (43)
- # pathom (56)
- # re-frame (37)
- # reagent (26)
- # shadow-cljs (161)
- # slack-help (9)
- # spacemacs (1)
- # tools-deps (18)
- # xtdb (18)
a noob question - datomic conn is a value of the db in time. So once I finish running a transaction, and if I want to run a query, do I need to use the new value of the db returned by the transaction ? basically if I have an app which is running queries and doing transactions. can I just have a global conn instantiated once at startup, or do I need to refresh the connection after every transaction ?
When you transact (successfully) against a connection object, a new db value is produced, so yes you need to retrieve it if you want to read the results of the transaction. (The map returned from transact has a db-before and db-after already, too)
But the connection object is unchanging—its a resource handle not a value (in fact it is already cached for you)
so after a transaction if I want to read the results of the transaction, can I just do (d/db connection-object)
instead of saving the db value returned by the transaction ?
I'm pretty sure the answer is yes but I can't find it in the docs.
If you are using the same connection object (same process or client) yes, but you are guaranteed a db at or after that tx, not the immediate next db
If you are on a different process, there may be propagation delays. In that case communicate the t to the other process then use d/sync to get a db guaranteed to be at or after the tx in question
@murtaza52 i don’t think client api has it but the Clojure cookbook has an example you can use: https://github.com/clojure-cookbook/clojure-cookbook/blob/1b3754a7f4aab51cc9b254ea102870e7ce478aa0/01_primitive-data/1-24_uuids.asciidoc
How do I use the collection binding form when performing a query as a map using d/query
https://docs.datomic.com/on-prem/query.html#bindings?
Just getting this error: Argument ... in :find is not a variable.
code? also, are you using the client api? (client api doesn’t support find destructuring)
(let [where ['[?dealer-id :dealer/listings ?listing-id]
'[?listing-id :listing/status :active]]
q {:find '[?listing-id '...]
:in ['$ '?dealer-id]
:where where}]
(d/query
{:query q
:args [(db)
17592186057265]}))
(let [where ['[?dealer-id :dealer/listings ?listing-id]
'[?listing-id :listing/status :active]]
q {:find ['[?listing-id ...]]
:in ['$ '?dealer-id]
:where where}]
(d/query
{:query q
:args [(db)
17592186057265]}))
would using datomic.ion/get-env
or datomic.ion/get-app-info
work?
what I do specifically rn (for other reasons) is check whether my own (System/getenv "LOCAL_ENV")
property has been set, and if it hasn’t I assume it’s running in an Ion. not sure if there’s a better way
That would tell me if the ion library is on the classpath, not if it's running in the Datomic environment. Current thinking is to check for the env var DATOMIC_ENV_MAP
i think DATOMIC_ENV_MAP
is the env var that datomic.ion/get-env
retrieves, hence my comment 🙂
Right but the difference is substantial. I may have Datomic ion lib on the classpath and not have the env var set.
i’m not sure I follow (from my understanding DATOMIC_ENV_MAP
is set by Datomic system, datomic.ion/get-env
just checks whether the env var is set or not which seems to be what you proposed to do anyway). in either case, was just suggesting a possible solution, maybe someone else can comment better