StackpressGitHub

API reference

Column

Column represents one field inside a model or fieldset. It owns helpers for name formatting, type metadata, assertions, components, value conversion, and store behavior.

Import

import { Column } from 'stackpress/schema';

Instantiation

Use Column.make(...) when creating a column from Idea-style tokens.

const title = Column.make('title', 'String');
title.addAttribute('label', [ 'Title' ]);

This example creates a string column and adds a label attribute. In most generator code, columns are read from model.columns or model.column(...).

Properties

PropertyTypeDescription
assertionColumnAssertionValidation/assertion helper.
attributesAttributesAttribute collection.
componentColumnComponentField/list/view component metadata helper.
documentColumnDocumentDocumentation metadata helper.
nameColumnNameName formatting helper.
numberColumnNumberNumeric metadata helper.
storeColumnStoreStore/query metadata helper.
typeColumnTypeType metadata helper.
valueColumnValueDefault/value metadata helper.
hasParentbooleanWhether the column is attached to a fieldset/model.
parentFieldsetParent fieldset or model. Throws if read before one is set.

Static Methods

Column.make(name, type, attributes?, parent?)

Builds a column from Idea-style tokens.

Returns a Column.

Instance Methods

addAttribute(attribute)

Adds an existing Attribute object.

Returns the column instance for chaining.

addAttribute(name, value)

Creates and adds an attribute.

ParameterTypeDescription
namestringAttribute name.
value`Data[] \boolean`Attribute args or boolean flag.

Returns the column instance for chaining.

attribute(name)

Finds an attribute by name.

Returns an Attribute when found, otherwise undefined.

const field = model.column('title');
const label = field?.attribute('label')?.value;

This example reads one column and then reads one attribute value from it.