ColumnFieldOptions
The options object accepted by @Column(). See
Data Columns for the full guide, including the type-inference rules
applied when type/dataType are omitted.
type ColumnFieldOptions = Partial<
Omit<ColumnFieldMetadata, 'entity' | 'name' | 'kind'>
>;
| Option | Type | Description |
|---|---|---|
fieldName | string | Database column name. Defaults to the property name if omitted. |
type | Function | JS constructor for the value (String, Number, Boolean, Date, Buffer, or an @Entity class). Inferred from the TS type when omitted. |
dataType | DataType | SQL data type — the DataType enum exported by @sqb/builder (BOOL, CHAR, VARCHAR, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, NUMBER, DATE, TIMESTAMP, TIMESTAMPTZ, TIME, BINARY, TEXT, GUID, JSON). Inferred from type when omitted. |
comment | string | Column comment. |
default | FieldValue | DefaultValueGetter | Default value used on create()/createOnly() when the field is null/undefined. Can be a literal or a (obj) => value function that receives the full input object. |
isArray | boolean | Marks the column as an array column. |
enum | EnumValue (FieldValue[] | Object) | Restricts accepted values; an array or an enum object (its Object.values() are used). Enforced on create/createOnly/update/updateOnly/updateMany — throws if the value isn't a member. |
length | number | Character/byte length. |
precision | number | Precision for a decimal field. |
scale | number | Scale for a decimal field. |
collation | string | Column collation. |
autoGenerated | ColumnAutoGenerationStrategy | 'increment' | 'uuid' | 'rowid' | 'timestamp' | 'custom'. Only a label consumed by Repository.create()/createOnly() (which columns to read back via RETURNING, and which columns are allowed to be absent despite notNull) — @sqb/connect never generates the value itself. |
notNull | boolean | Rejects null values on create/update with an Error, unless the column is also autoGenerated. |
noUpdate | boolean | Excludes the column from UPDATE statements (update/updateOnly/updateMany). |
noInsert | boolean | Excludes the column from INSERT statements (create/createOnly). |
parse | ColumnTransformFunction ((value, name) => any) | Transforms a raw database value into the property value when reading rows. Settable via @Parse instead. |
serialize | ColumnTransformFunction ((value, name) => any) | Transforms a property value into the value sent to the database when writing rows. Settable via @Serialize instead. |
hidden | boolean | Inherited from the shared field-metadata base (shared with AssociationFieldOptions and embedded fields); excludes the field from query results unconditionally, even when explicitly requested via projection. |
exclusive | boolean | Inherited from the shared field-metadata base; excludes the field from results by default — it's only returned when explicitly named in projection (see Repositories → Projection). |
ColumnFieldOptions is the property-bag form of ColumnFieldMetadata —
the same shape, minus the entity/name/kind fields that @sqb/connect fills in itself once
the decorator runs.