Skip to main content

ConstraintOptions

Type: Object

Defines additional constraints for a column within a Structure.

info
  • All keys in the object are optional
  • Only define the keys for the constraints you want to enable.

Example structure

{
"primary": true,
"index": true,
"null": true,
"unique": true,
"default": "Some default text",
"auto_increment": false,
"unsigned": true
}

Properties


.primary

Boolean

Defines if this column should be the primary key.


.index

Boolean

Marks the column as indexable (improves query speed but slows insertion).


.null

Boolean

Determines if the column allows NULL values by default.


.unique

Boolean

Ensures that all values in this column are unique, preventing duplicates.


.default

String

The default value inserted when no value is providded.


.auto_increment

Boolean

Increments the column value automatically on new insertions (typically used for primary keys).


.unsigned

Boolean

Defines whether the column should be unsigned (i.e., only allow non-negative numbers).

Warning

This option is only valid for numerical columns.