APIDemo

Schema

A schema describes multiple types. Every type contains fields and in many instances can be thought of as describing all of the data on a page.

schema('My schema', {
  TypeA, TypeB, TypeC
})

Example schema

The example below can be found in the configuration file after running the alinea init command. It has the following settings:


  • ...MediaSchema: include types needed for file uploads

  • type('Page', {...}): a type with two fields: title and path. After the fields a Welcome component is displayed in the dashboard. JSX can be used anywhere inside the type configuration the create custom views.

  • configure({isContainer: true}): mark the Page type as a container, which means it can contain sub pages

schema({
  ...MediaSchema,
  Page: type('Page',
    {
      title: text('Title'),
      path: path('Path')
    },
    <Welcome />
  ).configure({isContainer: true})
})

Types

/**
Create a schema, expects a string record of Type instances */
export function schema<Types extends LazyRecord<TypeConfig<any>>>(
types: Types
): SchemaConfig<TypeToEntry<TypeToRows<Types>>>
export namespace Schema {
/**
Utility to infer the type of a Schema, Type, Feld or any Store type */
}
/**
Describes the different types of entries */