This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-20
Channels
- # beginners (61)
- # cider (25)
- # cljsrn (7)
- # clojure (76)
- # clojure-austin (1)
- # clojure-russia (10)
- # clojure-uk (2)
- # clojurescript (96)
- # cursive (12)
- # datomic (38)
- # defnpodcast (9)
- # emacs (24)
- # fulcro (1)
- # graphql (5)
- # hoplon (3)
- # jobs (1)
- # keechma (20)
- # leiningen (4)
- # lumo (5)
- # off-topic (13)
- # perun (6)
- # re-frame (19)
- # reagent (1)
- # remote-jobs (2)
- # shadow-cljs (199)
- # sql (6)
- # vim (7)
Don’t panic
added [com.datomic/client-pro "0.8.14"] in project.clj and (:require [datomic.client.api :as d]) in core.clj but (def client (d/client cfg)) is producing a java.lang.Exception: namespace 'datomic.client.api' not found
just trying to follow along at https://docs.datomic.com/on-prem/getting-started/connect-to-a-database.html
thanks!
looks like there might be a different dep at https://docs.datomic.com/on-prem/project-setup.html
ok cool... no worries... and thanks for the help so far.
It was related to the clojure 1.8 issues mentioned above; switching to clojure 1.9 fixed the datomic.client.api not found issue. I accidentally reverted to 1.8. However, I can't use 1.9 in emacs atm as I haven't resolved my emacs/cider issue, which isn't a datomic issue, certainly.
Ah, glad you got it to work. I'm glad you found that other spot with the old dep I'll fix it this weekend
cool cool
I have a question about entity references (`:db.type/ref`) and history after reading https://docs.datomic.com/on-prem/entities.html#basics.
Suppose after the transactions in the example, Entity 42 ("Jane Doe") has :person/lastName
changed to "Smith". If you retrieved Entity "John" and traversed to the :person/lastName
of the Person
entity it refers to (42) will it return "Doe" still? The Entity reference seems to say this, just want to clarify:
>Navigation from an entity will always and only reach other entities with that same time basis
@jamesvickers19515 it depends on the basis t of the db value you pass to the query (or entity api call)
If you assert that Jane's last name is now Smith, then you got a new db value (ie with (d/db conn)) and looked at the last name of the person John likes it would be Smith.
If you assert the name change but then ask who John likes with the old db value you'll see the original last name. The db value is immutable
So if I wanted to value to still be "Doe" (i.e. not change) for the last name of who John likes, I'd have to track when the reference was associated right? As in keep a basis-t or time along with that reference?
I think a better example of what I'm asking about would be an Order that references a Customer entity. If the Customer's address changes later, you still might want to know that at the time the Order was made, the Customer entity had the old address.
Oh, maybe an easy way is to use the basis t of the entity itself - entity.db().basisT() - to find the version of Jane with the old last name? Thanks for the replies, I think a REPL session is in order.
I’m trying to write a spec that can cover a function that returns either an integer id, or a tempid. I feel like I’m missing something, perhaps there’s a better way to do it than this…?
(defn find-destination
“returns an id to either an existing destination or a tempid for insertion”
[dest]
{:pre [(s/valid? ::domain/url dest)]
:post [(s/valid? ::domain/entity-id %)]}
(let [db (d/db conn)
existing (ffirst (d/q ’[:find ?e
:in $ ?destination
:where
[?e :destination/url ?destination]]
(d/db conn)
dest))]
(or
existing
(d/tempid :db.part/user))))
@dazld if you are not doing explicit partition management, you should consider using string tempids. This solves your spec problem, and is also compatible with both On-Prem and Cloud
@dazld yes, str or int. And tempids are needed only when you need to link up related datoms (or manage partitions). Otherwise leave ’em out.
@jamesvickers19515 that's definitely an approach. You can also use an asOf database and/or a history db if you want to see the state of an entity or the whole history of an entity.