This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-03
Channels
- # admin-announcements (8)
- # beginners (99)
- # boot (60)
- # cider (44)
- # cljs-dev (47)
- # cljsrn (68)
- # clojure (223)
- # clojure-art (1)
- # clojure-russia (190)
- # clojure-sg (9)
- # clojure-uk (2)
- # clojurecup (1)
- # clojurescript (59)
- # clojurex (3)
- # core-async (43)
- # core-typed (2)
- # cursive (18)
- # datavis (7)
- # datomic (16)
- # events (2)
- # funcool (3)
- # hoplon (3)
- # jobs (1)
- # lein-figwheel (10)
- # leiningen (6)
- # off-topic (1)
- # om (123)
- # onyx (57)
- # parinfer (16)
- # portland-or (2)
- # random (1)
- # re-frame (4)
- # reagent (7)
- # remote-jobs (1)
- # spacemacs (12)
Datomic 0.9.5344 is now available https://groups.google.com/d/msg/datomic/LgGjHCF_CGw/HMzjhVLpBAAJ
must be the n00best question ever … but here goes … how do I get the data back after an add on the DB? The only twist is that there are components in the record being saved so I cannot tell which id is the resolved ID for the ‘outer’ object
(def cart {:cart/name "Bunky cart"
:cart/id (java.util.UUID/randomUUID)
:cart/sku-counts [{:sku-count/sku 12345
:sku-count/count 3
}
{:sku-count/sku 54321
:sku-count/count 4
}]})
=> #'shopping-cart-demo.datomic/cart
(save-new-cart conn cart)
{:db-before datomic.db.Db,
@db33bdaf :db-after,
datomic.db.Db @f673e86,
:tx-data [#datom[13194139534347 50 #inst"2015-12-03T20:15:35.122-00:00" 13194139534347 true]
#datom[17592186045452 64 "Bunky cart" 13194139534347 true]
#datom[17592186045452 63 #uuid"a192e41c-461a-44dc-a662-57ae652816d6" 13194139534347 true]
#datom[17592186045452 65 17592186045453 13194139534347 true]
#datom[17592186045453 66 12345 13194139534347 true]
#datom[17592186045453 67 3 13194139534347 true]
#datom[17592186045452 65 17592186045454 13194139534347 true]
#datom[17592186045454 66 54321 13194139534347 true]
#datom[17592186045454 67 4 13194139534347 true]],
:tempids {-9223354444667731342 17592186045454,
-9223354444667731343 17592186045453,
-9223350046623220336 17592186045452}}
I happen to know (from querying the DB manually) that the ID is the last one in the map
@raymcdermott: You have to hold on to something to reference the entity. It could be a unique identity, such as a UUID, to use in a lookup ref. Or keep the tempid and use resolve-tempid
to get the real Entity ID.
@stuartsierra: boom! worked a treat, thanks
You're welcome