@sqb/connect
Version:
Multi-dialect database connection framework written with TypeScript
70 lines (69 loc) • 1.71 kB
TypeScript
import { DataType } from '@sqb/builder';
import type { ColumnAutoGenerationStrategy, ColumnTransformFunction, DefaultValueGetter, EnumValue, FieldValue } from '../orm.type.js';
import { FieldMetadata } from './field-metadata.js';
export type ColumnFieldOptions = Partial<Omit<ColumnFieldMetadata, 'entity' | 'name' | 'kind'>>;
export interface ColumnFieldMetadata extends FieldMetadata {
readonly kind: 'column';
/**
Name of table field
*/
fieldName: string;
/**
JS type. String, Boolean, Person etc
*/
type?: Function;
/**
* Column data type
*/
dataType?: DataType;
/**
* Field comment
*/
comment?: string;
/**
* Column's default value
*/
default?: FieldValue | DefaultValueGetter;
/**
* Indicates if column data is an array
*/
isArray?: boolean;
/**
* Indicates enum values
*/
enum?: EnumValue;
/**
* Character or byte length of column
*/
length?: number;
/**
* The precision for a decimal field
*/
precision?: number;
/**
* The scale for a decimal field
*/
scale?: number;
/**
* Fields's collation.
*/
collation?: string;
/**
* Indicates auto generation strategy
*/
autoGenerated?: ColumnAutoGenerationStrategy;
/**
* Indicates if column value can be null
*/
notNull?: boolean;
/**
* Indicates if the column value is used in update queries
*/
noUpdate?: boolean;
/**
* Indicates if the column value is used in insert queries
*/
noInsert?: boolean;
parse?: ColumnTransformFunction;
serialize?: ColumnTransformFunction;
}