Store all your web app state in one DataScript database and query it with Datalog instead of scattering data across component-level variables.
Build an undo/redo system by keeping snapshots of immutable DataScript database versions across user actions.
Replace a client-side Redux store with DataScript to run richer relational queries across your application data.
Sync a browser DataScript state to a server-side Datomic database for persistence using a compatible library.
DataScript is an in-memory database and query engine designed to run inside a web browser or a Clojure application. The core idea is that creating a DataScript database should be about as simple and cheap as creating an ordinary data structure, like a dictionary or map. You create one on page load, fill it with your application's data, query it as needed, and discard it when the user closes the tab. The database is immutable, meaning that every change produces a new version rather than modifying the original in place. This makes it possible to track the full history of how your application's data changed over time, rewind to earlier states for undo/redo features, and always show a consistent snapshot of your data to the UI, even while updates are happening in the background. Instead of SQL, DataScript uses a query language called Datalog. Datalog lets you express questions about your data as patterns. For example, you can ask for all entities that share a certain attribute value, or follow relationships across multiple entities in a single query. Under the hood, a DataScript query is essentially a series of hashmap lookups and index scans, so it stays lightweight even without the machinery of a traditional database server. The library was built for client-side applications that track a lot of state. By storing everything in one DataScript database rather than scattered across component-local variables, different parts of an application, such as the renderer, a sync layer, or an undo stack, can each read the same state independently without stepping on each other. DataScript is available for Clojure, ClojureScript, and plain JavaScript. It is used by several well-known tools including Roam Research (a graph-based note-taking app), LogSeq (a local-first outliner notebook), and Athens Research (a networked thought tool). The README includes usage examples, links to tutorials, and a list of related libraries for things like syncing DataScript with a server-side Datomic database or persisting it to SQL storage.
← tonsky on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.