02 — Queryable views
Lens
Lens is the read-side: derived materialized views over one or many Strands. Snapshots, sub-DBs, fast iteration over arbitrary keyspaces, batched writes, cache-aware compaction. The source log is never touched.
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.
- 01Read the source
- 02Build a useful index
- 03Find the right record
01 — Concepts
01
Read-side projections of one or more Strands.
02
Snapshots, sub-DBs, batched writes, cache-aware compaction.
03
Source logs are never mutated.
04
Iteration over arbitrary keyspaces, byte-prefix scans.
02 — Code
A handful of lines.
use lens::{Lens, LensConfig};
let lens = Lens::open("./.weave/views/posts", LensConfig::default()).await?;
let mut tx = lens.batch();
tx.put(b"post:42", b"hello, world")?;
tx.commit().await?;
for (k, v) in lens.scan_prefix(b"post:") {
println!("{:?} -> {:?}", k, v);
}