DataScript implements a persistent EAV database and Datalog engine for Clojure, ClojureScript, and JavaScript. It targets client-side apps that need structured in-memory state without a remote SQL server.
Overview
DataScript is designed to live inside browser or lightweight JVM processes as an ephemeral, immutable database built on persistent data structures. You create a DB at page load, transact facts, run queries, and discard it when the session ends.
Indexes cover EAVT, AEVT, and AVET tuples with support for cardinality-many attributes, lazy reference entities, filtered databases, lookup refs, unique constraints, and upsert semantics. A Datalog query engine provides joins, rules, negation, disjunction, aggregates, and parameterized :in bindings over DBs or plain collections.
JavaScript callers can load the library without extra dependencies, use entity maps, and transact plain JS objects. ClojureScript users should configure shadow-cljs per upstream notes when bundling.
The API differs from Datomic in schema flexibility, lack of historical retention by default, and simplified attribute modeling, which keeps memory bounded for interactive web clients.
Key features
- In-memory immutable triple store
- Datalog queries and rules
- Clojure ClojureScript and JS APIs
- Multiple core indexes
- Transactions and entity maps
- Filtered database views
- Pull API support
- Client-side state centralization
Use cases
- Browser app state stores
- Undo-friendly UI modeling
- Offline-first prototypes
- Teaching Datalog concepts
- Lightweight graph-like facts