datascript

Immutable database and Datalog query engine for Clojure, ClojureScript and JS
hoppy 2019-02-09T03:52:52.069900Z

@tonsky, first - welcome back, second - are there plans to add a persistence backend to DS anytime soon?

2019-02-09T04:01:48.070400Z

in the browser, or on the client side?

hoppy 2019-02-09T13:12:07.075300Z

browsers are clients, so I assume you meant server. I don't see much use in a browser for anything other than the all-or-nothing serialization that is in ds now. for clj, cljs/node, something along the datahike path would be what I would be interested in hearing about. Maybe that question is already answered by dhike. Interested if there are alternate agendas

2019-02-09T15:11:24.078700Z

Question about Datascript schema: From a cursory look at the tests, it seems like the only purpose of schema in Datascript is so you can get it back out later with (:schema @conn). There is no other benefit to passing schema into your db instance, correct?

dpsutton 2019-02-09T15:18:55.079700Z

isn't schema necessary for basic querying and inserting? In particular, cardinality. Datascript must know if you are adding to a collection (card many) or replacing a single attribute (card one) right?

dpsutton 2019-02-09T15:37:12.080700Z

(let [schema {:aka {:db/cardinality :db.cardinality/many}}
      conn   (d/create-conn)]
  (d/transact! conn [ { :db/id -1
                       :name  "Maksim"
                       :age   45
                       :aka   ["Max Otto von Stierlitz", "Jack Ryan"] } ])
  (d/q '[:find  ?age ?aka
         :where
         [?e :name "Maksim"]
         [?e :age  ?age]
         [?e :aka ?aka]]
       @conn))
from the first example from the readme. If this is run with create-conn given no schema, this query returns #{[45 ["Max Otto von Stierlitz" "Jack Ryan"]]}.

dpsutton 2019-02-09T15:37:32.081100Z

Running with the schema included it returns #{[45 "Jack Ryan"] [45 "Max Otto von Stierlitz"]}

2019-02-09T15:50:37.082700Z

Ah, ok. Thanks. Is there any thing else that counts as the "special behavior" mentioned in the docs?

dpsutton 2019-02-09T16:12:02.084700Z

i'm looking for all of the schema that is supported but i can't find it. I see references to uniqueness, and declaring something is a ref. Ie, if it points to another thing in the db itself. for instance {:car/type 3}. Is this the integer 3 or the db/id 3 which could be {:manufacturer/make "subaru" :manufacturer/model "brz"} or whatever

✔️ 1