datascript

Immutable database and Datalog query engine for Clojure, ClojureScript and JS
dmrd 2018-02-25T00:53:00.000001Z

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

2018-02-25T02:22:27.000070Z

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

2018-02-25T09:15:59.000009Z

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

2018-02-25T20:49:37.000055Z

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?

2018-02-25T20:59:35.000079Z

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