Fork me on GitHub
#datascript
<
2019-02-09
>
hoppy03:02:52

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

Braden Shepherdson04:02:48

in the browser, or on the client side?

hoppy13:02:07

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

Daniel Hines15:02:24

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?

dpsutton15:02:55

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?

dpsutton15:02:12

(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"]]}.

dpsutton15:02:32

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

Daniel Hines15:02:37

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

dpsutton16:02:02

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

✔️ 5