Skip to content

API > @blocksuite/store > defineBlockSchema

Function: defineBlockSchema ​

defineBlockSchema<Flavour, Role, Props, Ext, Metadata, Model, Transformer>(options): object

Type parameters ​

Parameter
Flavour extends string
Role extends "root" | "hub" | "content"
Props extends object
Ext extends Record< string, unknown >
Metadata extends Readonly< {children: string[]; parent: string[]; role: Role; version: number;} >
Model extends BaseBlockModel< Props >
Transformer extends BaseBlockTransformer< Props >

Parameters ​

ParameterType
optionsobject
options.flavourFlavour
options.metadataMetadata
options.onUpgrade?function
options.props?function
options.toModel?function
options.transformer?function

Returns ​

model ​

model: {flavour: Flavour; props: PropsGetter< Props >; role: Role;} & Metadata

model.flavour ​

flavour: Flavour

model.props ​

props: PropsGetter< Props >

model.role ​

role: Role

onUpgrade ​

optional onUpgrade: function

Parameters ​

ParameterType
dataProps
previousVersionnumber
latestVersionnumber

Returns ​

void

transformer ​

optional transformer: function

Returns ​

Transformer

version ​

version: number

Defined In ​

packages/store/src/schema/base.ts:76