Column

The Column class in SchemaJS defines the structure and properties of a column within a table. Each column has a name, data type, optional default value, and additional properties such as whether it is required or acts as a primary key. The Column class provides several methods for customizing the behavior and constraints of the column, making it flexible and powerful for defining database schemas.

Constructor

new Column(name: string, dataType?: DataTypes)

string

Sets the column's data type to String.

column.string()

boolean

Sets the column's data type to Boolean.

column.boolean()

require

Whether the column is required to exist during insertion.

column.require(data: boolean)

withComment

Adds a comment or description to the column for documentation purposes.

withDefaultValue

Sets a default value for the column. The value is validated to ensure it matches the column's data type.

The value is validated to ensure it matches the column's data type.

Last updated