@tonsky, first - welcome back, second - are there plans to add a persistence backend to DS anytime soon?
in the browser, or on the client side?
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
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?
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?
(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"]]}
.Running with the schema included it returns #{[45 "Jack Ryan"] [45 "Max Otto von Stierlitz"]}
Ah, ok. Thanks. Is there any thing else that counts as the "special behavior" mentioned in the docs?
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