Upgrade to Pro — share decks privately, control downloads, hide ads and more …

DataScript for Web Development

DataScript for Web Development

DataScript is an open-source implementation of Datalog and Datomic in-memory storage, in ClojureScript, for browser. Here I talk about motivation behind DataScript, how it was created, how it can be used, what kind of problems it solves and how simple and sane web app development is when you have a database in your browser.

Nikita Prokopov

December 04, 2014
Tweet

More Decks by Nikita Prokopov

Other Decks in Programming

Transcript

  1. (def conn (d/create-conn {:aka {:db/cardinality :db.cardinality/many }})] (d/transact! conn [

    {:db/id 1 :name “Ivan” :aka [“The Terrible”, “Durak”]}]) (d/q ‘[:find ?name :where [?e :aka “Durak”] [?e :name ?name]] @conn)
  2. 700 loc btset 550 loc query engine 1700 loc total

    1200 loc tests DataScript is lightweight
  3. Datoms, DB and transactions have standard way to be serialized

    No need to invent format for delta exchange
  4. Whole DB prefetch: no server fetch on any navigation, all

    queries and aggregations hap- pen on a client
  5. Optimized for huge amount of listeners, e.g. every person component

    ever can subscribe to [(:db/id person) :person/name _]
  6. Similar to Om ref-cursors Have to figure out how to

    play nicely with top-down rendering
  7. Occasional breaking changes (not significant though) If it’s in Datomic

    and DataScript already, it probably won’t change