Skip to main content

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'>
>;
OptionTypeDescription
fieldNamestringDatabase column name. Defaults to the property name if omitted.
typeFunctionJS constructor for the value (String, Number, Boolean, Date, Buffer, or an @Entity class). Inferred from the TS type when omitted.
dataTypeDataTypeSQL 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.
commentstringColumn comment.
defaultFieldValue | DefaultValueGetterDefault 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.
isArraybooleanMarks the column as an array column.
enumEnumValue (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.
lengthnumberCharacter/byte length.
precisionnumberPrecision for a decimal field.
scalenumberScale for a decimal field.
collationstringColumn collation.
autoGeneratedColumnAutoGenerationStrategy'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.
notNullbooleanRejects null values on create/update with an Error, unless the column is also autoGenerated.
noUpdatebooleanExcludes the column from UPDATE statements (update/updateOnly/updateMany).
noInsertbooleanExcludes the column from INSERT statements (create/createOnly).
parseColumnTransformFunction ((value, name) => any)Transforms a raw database value into the property value when reading rows. Settable via @Parse instead.
serializeColumnTransformFunction ((value, name) => any)Transforms a property value into the value sent to the database when writing rows. Settable via @Serialize instead.
hiddenbooleanInherited 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.
exclusivebooleanInherited 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.