Type alias ColumnType<SelectType, InsertType, UpdateType>

ColumnType<SelectType, InsertType, UpdateType>: {
    __insert__: InsertType;
    __select__: SelectType;
    __update__: UpdateType;
}

This type can be used to specify a different type for select, insert and update operations.

Also see the Generated type.

Examples

The next example defines a number column that is optional in inserts and updates. All columns are always optional in updates so therefore we don't need to specify undefined for the update type. The type below is useful for all kinds of database generated columns like identifiers. The Generated type is actually just a shortcut for the type in this example:

ColumnType<number, number | undefined, number>

The above example makes the column optional in inserts and updates, but you can still choose to provide the column. If you want to prevent insertion/update you can se the type as never:

ColumnType<number, never, never>

Here's one more example where the type is different for each different operation:

ColumnType<Date, string, never>

Type Parameters

  • SelectType

  • InsertType = SelectType

  • UpdateType = SelectType

Type declaration

  • Readonly __insert__: InsertType
  • Readonly __select__: SelectType
  • Readonly __update__: UpdateType

Generated using TypeDoc