Skip to content

02 — Queryable views

Lens

Lens is a sorted key/value abstraction built on a Strand-backed B-tree. Use keys, ranges and snapshots to query records or maintain an application projection. It does not provide a transaction across other abstractions; check current batch and recovery limitations.

A closer lookA clearer view of your own history.

Source records become a queryable view. The index helps you find the record without replacing its provenance.

  1. 01Read the source
  2. 02Build a useful index
  3. 03Find the right record
01 — Concepts
01

Sorted key/value B-tree backed by Strand.

02

Snapshots and range access; check current batching and recovery limits.

03

Source logs are never mutated.

04

Iteration over arbitrary keyspaces, byte-prefix scans.

02 — Code

A handful of lines.

// Given a configured WeaveNode and an authorized existing Lens.
node.open_existing_lens("index").await?;
node.lens_put("index", b"document:42", b"event-reference").await?;
let value = node.lens_get("index", b"document:42").await?;