Principle:AFK surf Open agent Cell Value Mutation
| Knowledge Sources | |
|---|---|
| Domains | Database, Data_View, BlockSuite |
| Last Updated | 2026-10-25 00:00 GMT |
Overview
Pattern of writing a typed value into a database cell (row id × property id) through the data source adapter so the CRDT and reactive signals stay in sync.
Description
A database cell is addressed by a row id (a child block of the database) and a property id (a column). Writing a cell value goes through datasource.cellValueChange(rowId, propertyId, value). The value type depends on the column: rich-text columns take a Text instance, number columns take a number, checkbox columns take a boolean, multi-select columns take an array of option ids. The data source persists the value into the yjs cell map and the reactive signals (cellValueGet$) update. Direct mutation of the block model's cells map bypasses the adapter and breaks reactivity.
Usage
Apply this principle whenever you populate or edit database cells programmatically. Pair with store.addBlock (which creates the row block) and propertyAdd (which creates the column).
Theoretical Basis
The cell map is a 2D slot: Cell[rowId][propertyId] = value. The adapter is the single writer; it updates the CRDT, which propagates to subscribers via signals. cellValueGet$(rowId, propertyId) returns a ReadonlySignal that re-evaluates when the cell changes.
Pseudo-code:
const rowId = store.addBlock('affine:paragraph', { text: new Text(t) }, databaseId);
datasource.cellValueChange(rowId, richTextId, new Text(t));