This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-18
Channels
- # bangalore-clj (1)
- # beginners (60)
- # boot (98)
- # cider (8)
- # clojure (158)
- # clojure-dusseldorf (16)
- # clojure-france (3)
- # clojure-hamburg (2)
- # clojure-mke (2)
- # clojure-russia (11)
- # clojure-serbia (1)
- # clojure-spec (123)
- # clojure-uk (59)
- # clojurescript (44)
- # code-reviews (16)
- # community-development (51)
- # core-async (46)
- # cryogen (1)
- # cursive (9)
- # datascript (5)
- # datomic (36)
- # emacs (3)
- # events (12)
- # hoplon (57)
- # jobs (1)
- # juxt (3)
- # klipse (55)
- # lein-figwheel (3)
- # leiningen (5)
- # luminus (3)
- # off-topic (8)
- # om (75)
- # om-next (9)
- # onyx (17)
- # pedestal (7)
- # portland-or (3)
- # proton (36)
- # protorepl (6)
- # re-frame (3)
- # reagent (33)
- # remote-jobs (1)
- # ring (23)
- # ring-swagger (2)
- # rum (1)
- # specter (1)
- # untangled (36)
- # yada (11)
@tmorten Ah are you providing the entity IDs yourself? I have not done it that way. I have simply provided the name and the value and I let Datomic resolve which EID it is.
I found a bug in some of my logic that was causing the issue. Thanks for your help, though, @sova
hi, is it possible to query when a :db/id
was created? == tx
of :db/id
anytime @tmorten . glad you got it resolved. so db.fn/retractEntity just needs the eid? that is nice.
i guess not since :db/id
is just one part of the index (entity) and you can't transact a db/id
on its own i think, so only with the rest A/V/op you have a tx
.. well i can always use [?e _ _ ?tx]
Is it possible to update multiple entities in a single transaction? something like:
(d/transact conn {:db/id [123 126] :my-entity/value “YAY”})
@andrethehunter not the way you’ve declared it. (d/transact conn [{:db/id 123 :my-entity/value “YAY”} {:db/id 126 :my-entity/value “YAY”}])
@robert-stuttaford what if the entity ids are not known and need to be found? a "nested" query. something like: (d/transact conn {:db/id [[:find ?e :where [?e :my-entity/value "Nay"]] :my-entity/value "YAY"})
the only way I've found was to create a datomic function via db/fn and then use that in two transactions
this seemed overly complicated and verbose
is there a simpler way?
what problem are you trying to solve by doing it this way, @andrethehunter ?
do you need to find and update it inside a consistent transaction?
if not, surely (let [id (d/q …)] @(d/transact conn [{:db/id id …}]))
is sufficient?
@andrethehunter: if you don't know the entity id, then you could also use the lookup ref (hopefully you have another identifier in your entity).
@andrethehunter I'd also be curious what you mean by "need to be found". Maybe you could give an example?
My approach has been to generally ignore entity IDs and use lookup refs in their place. I'm guessing most people do the same?
Lookup refs are generally easy to work with. There's one place you can't use a lookup ref: In the same transaction that created the entity you're looking up.
@tmorten i sway to the oposite, lookup refs throw, finding entity id myself gives me finer control over what happens
but maybe someone could elaborate on pros and cons?
I agree with @tmorten, I always use lookup refs
and treat entity ids as a sort of implenetation detail
Both have their uses. Most Datomic API functions will accept either an Entity ID or a lookup ref.
Sorry to repeat my questions, unable find any answers online 🙂 Is there a simple way to clear the object cache for benchmarking sake? (Does releasing the connection work?) And on an unrelated note is is possible to limit a many cardinality ref relationship in datalog, so that the where clause only applies to the newest for example?
@mbutler cardinality/many attributes don’t have any sense of ‘order’, they’re based on set semantics, so if you need to identify one element of the set you’d need to do it based on a secondary attribute of the referenced entity
Awesome, thanks :thumbsup:
I’ll have to think more about how to construct my query then @marshall maybe ask for the :db/id
s of them all and get the first largest somehow. Alternatively may be better to flip the query on its head and traverse the ref in the other direction.
Thanks again 🙂