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 PropertyAdd

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

Overview

Concrete API for adding a typed property (column) to a data source at a given position, using a property type from a preset config.

Description

datasource.propertyAdd inserts a new column into the data source. It takes an InsertToPosition ('end' to append, or a numeric index) and an options bag carrying the property type string (from a property config's .type field) and a display name. The property type drives cell rendering, filter matching, group-by behavior, and conversions. Available property types come from two barrels: propertyPresets (multi-select, date, number, checkbox, progress, select, image, text) and databaseBlockProperties (rich-text and link columns specific to the database block).

Usage

Call this after wrapping a database with a DatabaseBlockDataSource and adding at least one view. Iterate over the preset configs to add a set of typed columns, or add a single column for a targeted use case.

Code Reference

Source Location

  • Repository: Open-Agent
  • File: interface at blocksuite/affine/data-view/src/core/data-source/base.ts (L62-68); usage in blocksuite/playground/apps/starter/data/database.ts (L48-64); preset barrel at blocksuite/affine/data-view/src/property-presets/index.ts (L13-22)

Signature

interface DataSource {
  propertyAdd(
    insertToPosition: InsertToPosition,
    ops?: { type?: string; name?: string }
  ): string | undefined;
}

// Property preset barrel:
const propertyPresets = {
  checkboxPropertyConfig,
  datePropertyConfig,
  imagePropertyConfig,
  multiSelectPropertyConfig,
  numberPropertyConfig,
  progressPropertyConfig,
  selectPropertyConfig,
  textPropertyConfig,
};

Import

import { propertyPresets } from '@blocksuite/data-view/property-presets';
import { databaseBlockProperties } from '@blocksuite/affine/blocks/database';
// propertyAdd is a method on the datasource instance

I/O Contract

Inputs

Name Type Required Description
insertToPosition InsertToPosition Yes 'end' to append, or a numeric index
ops.type string Yes Property type string, e.g. propertyPresets.multiSelectPropertyConfig.type
ops.name string No Display name for the column

Outputs

Name Type Description
propertyId undefined The id of the new column; use it with cellValueChange

Usage Examples

Add a Rich-Text and a Multi-Select Column

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

datasource.propertyAdd('end', {
  type: propertyPresets.multiSelectPropertyConfig.type,
  name: propertyPresets.multiSelectPropertyConfig.config.name,
});

Iterate Over All Standard Presets

Object.values([
  propertyPresets.multiSelectPropertyConfig,
  propertyPresets.datePropertyConfig,
  propertyPresets.numberPropertyConfig,
  databaseBlockProperties.linkColumnConfig,
  propertyPresets.checkboxPropertyConfig,
  propertyPresets.progressPropertyConfig,
]).forEach(column => {
  datasource.propertyAdd('end', { type: column.type, name: column.config.name });
});

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

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