Fork me on GitHub

Unrelated question: is there a simple way to get the id of newly created entities? Having trouble getting the datoms out of the new db: (:db-after (d/transact! [new datoms with -1 db/id])) will get the new db state, but unable to then get the :datoms field out of it


If you look at the rest of the outputs of d/transact! you'll see it should include tempid resolutions.


@ritt93 you can persist datoms and then load them back up

Drew Verlee20:02:37

In the example in the docs:

(require '[datascript.core :as d])

;; Implicit join, multi-valued attribute

(let [schema {:aka {:db/cardinality :db.cardinality/many}}
      conn   (d/create-conn schema)]
  (d/transact! conn [ { :db/id -1
                        :name  "Maksim"
                        :age   45
                        :aka   ["Max Otto von Stierlitz", "Jack Ryan"] } ])
  (d/q '[ :find  ?n ?a
          :where [?e :aka "Max Otto von Stierlitz"]
                 [?e :name ?n]
                 [?e :age  ?a] ]

;; => #{ ["Maksim" 45] }
are :name, :age and :aka considered idents?

Drew Verlee20:02:35

So schema {:aka {:db/cardinality :db.cardinality/many}} is basically {ident {schemaKey schemaValue}}`