datascript

Immutable database and Datalog query engine for Clojure, ClojureScript and JS
lilactown 2020-08-01T01:03:02.124100Z

ok, another dumb question

lilactown 2020-08-01T01:03:15.124400Z

how do I transact something with a lookup ref?

lilactown 2020-08-01T01:04:19.125300Z

given this schema:

(def ^:private schema
  {::node-id {:db/unique :db.unique/identity}})
doing this:
(ds/db-with (ds/empty-db schema)
            [{::node-id "root"}
             {::node-id "seg-asdf"
              ::node-type ::segment/v3
              ::parent [::node-id "root"]}])
just seems to store [::node-id "root"] literally in the ::parent attribute of the 2nd entity, rather than storing an entity-id

lilactown 2020-08-01T04:00:13.125800Z

ah ok, I needed to add {:db/valueType :db.type/ref} to the schema for ::parent

🎉 1