ФреймворкJavaScript
База данных: схема, представления и строки
A multi-view database block supporting board (Kanban), list, table, and gallery views. Stores a schema of typed properties (text, select, multiSelect, date, checkbox, etc.) and view configurations. Rows are stored as child `database-row` blocks. Supports grouping, sorting, filtering, drag-and-drop reordering, inline editing, and an optional backend sync adapter.
Импорт
TypeScript
import { Database } from '@bloklabs/core/tools';Конфигурация
| Опция | Тип | По умолчанию | Описание |
|---|---|---|---|
adapter | DatabaseAdapter | undefined | Optional backend sync adapter for persisting schema, row, and view changes to an external data source. |
Формат данных
TypeScript
interface DatabaseData {
title?: string; // Database title
schema: PropertyDefinition[]; // Column definitions (id, name, type, position, config)
views: DatabaseViewConfig[]; // View configs (board, list, table, gallery)
activeViewId: string; // Currently active view ID
}
// Rows are NOT stored here — they are child database-row blocks.JSON
{
"id": "db001",
"type": "database",
"data": {
"title": "Tasks",
"schema": [
{ "id": "prop1", "name": "Name", "type": "title", "position": "a0" },
{ "id": "prop2", "name": "Status", "type": "select", "position": "a1" }
],
"views": [
{
"id": "v1",
"name": "Board",
"type": "board",
"position": "a0",
"sorts": [],
"filters": [],
"visibleProperties": ["prop1", "prop2"]
}
],
"activeViewId": "v1"
}
}Пример использования
TypeScript
import { Blok } from '@bloklabs/core';
import { Database } from '@bloklabs/core/tools';
const editor = new Blok({
holder: 'editor',
tools: {
database: {
class: Database,
},
},
});