Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AFK surf Open agent DataSource CellValueChange

From Leeroopedia
Knowledge Sources
Domains Database, Data_View, BlockSuite
Last Updated 2026-10-25 00:00 GMT

Overview

Concrete API for writing a cell value into a database row/property pair through the DataSource adapter.

Description

datasource.cellValueChange is the write primitive for database cells. Given a row id (a child block id under the database), a property id (a column id from propertyAdd), and a value, it persists the value into the yjs cell map. Rich-text columns take a Text instance; other typed columns take primitives (number, boolean) or option-id arrays (multi-select). Always use this method instead of mutating the block model's cells map directly so the data-view reactivity stays in sync.

Usage

Call this after adding properties and row blocks. Used to populate the rich-text column (and any other typed column) for each row block in the database preset.

Code Reference

Source Location

  • Repository: Open-Agent
  • File: interface at blocksuite/affine/data-view/src/core/data-source/base.ts (L28, abstract L140-150); usage in blocksuite/playground/apps/starter/data/database.ts (L87-92, L103-108)

Signature

interface DataSource {
  cellValueGet(rowId: string, propertyId: string): unknown;
  cellValueGet$(rowId: string, propertyId: string): ReadonlySignal<unknown | undefined>;
  cellValueChange(rowId: string, propertyId: string, value: unknown): void;
}

Import

// cellValueChange is a method on the datasource instance:
const datasource = new DatabaseBlockDataSource(database);

I/O Contract

Inputs

Name Type Required Description
rowId string Yes The row block id (a child block of the database)
propertyId string Yes The column id returned by propertyAdd
value unknown Yes Text for rich-text columns; primitives/arrays for others

Outputs

Name Type Description
(void) void The cell value is persisted; reactive signals update

Usage Examples

Populate a Rich-Text Cell for Each Row

const richTextId = datasource.propertyAdd('end', {
  type: databaseBlockProperties.richTextColumnConfig.type,
  name: 'Rich Text',
});

const rowId = store.addBlock(
  'affine:paragraph',
  { type: 'text', text: new Text('Row content') },
  databaseId
);
datasource.cellValueChange(rowId, richTextId, new Text('Row content'));

Read a Cell Reactively

const cellSignal = datasource.cellValueGet$(rowId, richTextId);
console.log(cellSignal.value); // current value, updates reactively

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment