Skip to content

Core Data Model

The core data model lives in @blocknote/block-view/core. All entities auto-register with an EntityRegistry on construction, enabling automatic relationship resolution.

The schema definition for a set of documents. A collection owns the property schema and tracks its documents.

import { Collection } from "@blocknote/block-view/core";
PropertyTypeDescription
idstringUnique identifier
namestringDisplay name
schemaRecord<string, Property>Property definitions keyed by property ID
documentsMap<string, Document>Documents keyed by document ID
sizenumberNumber of documents
viewCollectionViewThe primary view (resolved via registry)
role"editor" | "reader"Current user’s permission level
createdByReferenceWho created this collection
createdAtnumberCreation timestamp
updatedAtnumberLast update timestamp
updatedByReferenceWho last updated
registryEntityRegistryThe registry this entity belongs to
collection.getDocument(id: string): Document | undefined
collection.toJSON(): CollectionJSON
Collection.fromJSON(json: CollectionJSON, registry: EntityRegistry): Collection
// Access the schema
const nameProperty = collection.schema["name"];
console.log(nameProperty.label); // "Name"
console.log(nameProperty.type); // "string"
// Iterate documents
for (const [id, doc] of collection.documents) {
console.log(id, doc.getProp("name")?.value);
}

A presentation layer over a collection. Controls which columns are visible, their widths, filters, sorts, and row ordering.

import { CollectionView } from "@blocknote/block-view/core";
PropertyTypeDescription
idstringUnique identifier
type"table" | "kanban" | "calendar" | "gallery"View type
collectionIdstringParent collection ID
collectionCollectionParent collection (resolved via registry)
columnsArray<{ property: Property; width?: number; visible?: boolean }> | undefinedColumn configuration
filtersFilter[] | undefinedActive filters
sortsArray<{ property: Property; desc: boolean }> | undefinedActive sorts
manualSortOrderArray<string>Manual row ordering (document IDs)
role"editor" | "reader"Permission level
createdByReferenceCreator
createdAtnumberCreation timestamp
updatedAtnumberLast update timestamp
updatedByReferenceLast updater
view.toJSON(): CollectionViewJSON
CollectionView.fromJSON(json: CollectionViewJSON, registry: EntityRegistry): CollectionView

When serialized (e.g., for data sources), a CollectionView looks like:

{
id: "view-1",
type: "table",
collectionId: "tasks",
manualSortOrder: ["doc-1", "doc-2", "doc-3"],
filters: undefined,
sorts: undefined,
columns: [
{ propertyId: "name", width: 250, visible: true },
{ propertyId: "status", width: 150, visible: true },
],
createdBy: { type: "user", id: "me" },
createdAt: 1700000000000,
updatedAt: 1700000000000,
updatedBy: { type: "user", id: "me" },
role: "editor",
}

A single row/record in a collection. Contains property values as key-value pairs.

import { Document } from "@blocknote/block-view/core";
PropertyTypeDescription
idstringUnique identifier
collectionIdstringParent collection ID
collectionCollectionParent collection (resolved via registry)
propsRecord<string, PropertyValue>Values keyed by property ID
metaRecord<string, unknown> | undefinedOptional metadata
role"editor" | "reader"Permission level
createdByReferenceCreator
createdAtnumberCreation timestamp
updatedAtnumberLast update timestamp
updatedByReferenceLast updater
document.getProp(propertyId: string): PropertyValue | undefined
document.toJSON(): DocumentJSON
Document.fromJSON(json: DocumentJSON, registry: EntityRegistry): Document
const doc = collection.documents.get("doc-1");
const name = doc.getProp("name");
console.log(name?.value); // "Design data model" (always a string)

A column/property definition in the collection schema. Describes the type, label, and constraints for a property.

import { Property } from "@blocknote/block-view/core";
PropertyTypeDescription
idstringUnique identifier
collectionIdstringParent collection ID
collectionCollectionParent collection (resolved via registry)
labelstringDisplay label
typestringProperty type ("string", "number", "date", "checkbox", "single-select", "multi-select", or custom)
descriptionstring | undefinedOptional description
iconstring | undefinedOptional icon identifier
readonlybooleanWhether the property is read-only
enumreadonly PropertyEnumOption[] | undefinedOptions for select types
formatstring | undefinedFormat hint ("date", "date-time", "email", "uri", etc.)
minimumnumber | undefinedMinimum value (for numbers)
maximumnumber | undefinedMaximum value (for numbers)
type PropertyEnumOption = {
value: string | number | boolean;
label?: string;
color?: string;
};

Used by single-select and multi-select properties to define the available choices:

{
type: "single-select",
enum: [
{ value: "todo", label: "To Do", color: "gray" },
{ value: "in-progress", label: "In Progress", color: "blue" },
{ value: "done", label: "Done", color: "green" },
],
}

A single cell value. All values are stored as strings for CRDT compatibility. The string is parsed at display time based on the property’s type.

import { PropertyValue } from "@blocknote/block-view/core";
PropertyTypeDescription
idstringUnique identifier
valuestringThe stored value (always a string)
refReference | undefinedOptional reference to an external resource
documentIdstringParent document ID
propertyIdstringParent property ID
documentDocumentParent document (resolved via registry)
propertyPropertyParent property (resolved via registry)

Values are always strings, regardless of property type:

Property typeStored value example
string"Hello world"
number"42"
date"2024-01-15"
checkbox"true" or "false"
single-select"done"
multi-select"tag1,tag2,tag3" (comma-separated)

A typed reference to an external resource (user, document, workspace, etc.).

import { Reference } from "@blocknote/block-view/core";
PropertyTypeDescription
typestringResource type (e.g., "user", "document")
idstringResource ID
const userRef = new Reference({ type: "user", id: "alice" });
console.log(userRef.type); // "user"
console.log(userRef.id); // "alice"

Central lookup system for all entities. Entities auto-register on construction. Enables relationship resolution — when you access document.collection, the registry resolves it.

import { EntityRegistry } from "@blocknote/block-view/core";

You rarely interact with the registry directly. It’s created internally by initializeCollection and passed to all entities.

import { isFilterRule, isFilterGroup } from "@blocknote/block-view/core";
interface FilterRule {
id: string;
propertyId: string;
operator: string;
value: string;
}
interface FilterGroup {
id: string;
logicalOperator: "AND" | "OR";
children: Array<Filter>;
}
type Filter = FilterRule | FilterGroup;
isFilterRule(filter: Filter): filter is FilterRule
isFilterGroup(filter: Filter): filter is FilterGroup
import {
DatabaseError,
NotFoundError,
ValidationError,
NetworkError,
} from "@blocknote/block-view/core";
ClassExtendsDescription
DatabaseErrorErrorBase error for all library errors
NotFoundErrorDatabaseErrorEntity not found
ValidationErrorDatabaseErrorInvalid input data
NetworkErrorDatabaseErrorHTTP/network failure. Has optional statusCode: number