This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-01
Channels
- # beginners (10)
- # cljs-dev (33)
- # cljsjs (4)
- # cljsrn (12)
- # clojure (39)
- # clojure-belgium (2)
- # clojure-russia (80)
- # clojure-spec (9)
- # clojure-uk (6)
- # clojurescript (22)
- # core-async (141)
- # cursive (2)
- # datomic (20)
- # devops (1)
- # emacs (20)
- # hoplon (1)
- # jobs (3)
- # lambdaisland (12)
- # leiningen (3)
- # lumo (44)
- # onyx (2)
- # pedestal (1)
- # quil (1)
- # re-frame (9)
- # reagent (4)
- # robots (1)
- # rum (3)
- # spacemacs (5)
- # uncomplicate (80)
- # untangled (46)
- # yada (2)
@dimovich if said entities have a unique attribute, you can typically use the t of the corresponding datom
It's hard to help you more without additional context
@val_waeselynck I'll look for the moment at tempids. Thanks for the info
if I transact an entity with same id, the new items will be conjoined to the original :items
@dimovich You need a transaction function for that. See for instance the one in Datofu https://github.com/vvvvalvalval/datofu#resetting-to-many-relationships
@val_waeselynck thanks!
No, but when you think about it, there isnt either for sql databases.
btw, whenever I make a transaction, if I do a query afterwards (against the new db value) I don't get the new entities
@dimovich db
is immutable. Once you get a db (let [db (d/db conn)] )
, it will NEVER change. If you want a new db, you can make a new (d/db conn)
, or in case of a transaction, a transaction returns a future, that you can deref and get the db-after
and db-before
.
(defn handler
[req]
(let [db (get req :db)
conn (get req :conn)
params (get req :params)
tx-data (do-stuff db params)
tx (d/transact conn tx-data)
db-after (get @tx :db-after)]
(my-query-stuff db-after params)))
About "to-many" problem, [{:id "foo" :items [1 2]}]
is a sugar syntax to [[:db/add [:id "foo"] :items 1][:db/add [:id "foo"] :items 2]]
. If you want to remove a thing from a many, you should explicit do it.
In my app, there is a generic (update-to-many db x)
, that walk across all maps, identify it, check to many atributes, compare with database and generate the retracts...