Quickstart

Create a table, define a live view over it, and watch ReifyDB keep that view up to date as the data changes. Right here in your browser, nothing to install.

This page is a real database
Every snippet below runs against a real ReifyDB engine compiled to WebAssembly. Click Run on each snippet, top to bottom. You can edit any of them.

1. Create a table

Tables hold authoritative state. Every table lives in a namespace and is addressed as namespace::table:

Create a Table
create namespace shop;
create table shop::orders { id: int4, item: utf8, amount: float8, status: utf8 }

2. Define a live view

A transactional view is derived state. You declare the query once; ReifyDB maintains the result incrementally, inside the same transaction as every write that affects it. No polling, no cache invalidation, no batch refresh:

Create a Transactional View
create transactional view shop::open_orders { id: int4, item: utf8, amount: float8 } as {
  from shop::orders
  filter { status == "open" }
  map { id, item, amount }
}

The view tracks changes from the moment it is created, so we define it before inserting data.

3. Insert rows

INSERT takes an array of records:

Insert Rows
INSERT shop::orders [
  { id: 1, item: "keyboard", amount: 89.0, status: "open" },
  { id: 2, item: "monitor", amount: 349.5, status: "open" },
  { id: 3, item: "cable", amount: 12.5, status: "shipped" },
  { id: 4, item: "desk", amount: 420.0, status: "shipped" }
]

4. Query the table

RQL queries are pipelines. Start with from, then chain steps; each line transforms the output of the line above it:

Query the Table
from shop::orders
filter { status == "open" }
sort { id: asc }

5. Query the view

The view already contains the two open orders. Nothing recomputed the query; the inserts themselves maintained it:

Query the View
from shop::open_orders
sort { id: asc }

6. Change the data

Ship the keyboard order:

Update a Row
UPDATE shop::orders { status: "shipped" } FILTER { id == 1 }

Then query the view again. The shipped order is gone, because the view's filter no longer matches it:

The View Maintained Itself
from shop::open_orders
sort { id: asc }

7. Aggregate

Pipelines end wherever you need them to. Group and aggregate with aggregate ... by:

Aggregate Revenue by Status
from shop::orders
aggregate { revenue: math::sum(amount), orders: math::count(id) } by { status }
sort { status: asc }

Where next

  • --RQL in five minutes - the query language, one concept at a time
  • --Installation - run ReifyDB for real, embedded or as a server
  • --Concepts - what an application state database is and when to use one