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
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] ]
@conn))
;; => #{ ["Maksim" 45] }
are :name, :age and :aka
considered idents?So schema {:aka {:db/cardinality :db.cardinality/many}}
is basically {ident {schemaKey schemaValue}}`