Interface TableMapperTransforms<DB, TB, KeyColumns, SelectedColumns, SelectedObject, InsertedObject, UpdatingObject, ReturnCount, InsertReturnColumns, UpdateReturnColumns, InsertReturn, UpdateReturn>

Transformations to apply to values provided to and received from queries. All transformations are optional. When no transformation is provided, the value is passed through unchanged.

Type Param

of the count of the number of affected rows.

Type Parameters

  • DB

    Interface whose fields are table names defining tables.

  • TB extends keyof DB & string

    Name of the table.

  • KeyColumns extends Readonly<SelectableColumnTuple<DB[TB]>> | Readonly<[]> = []

    Tuple of the names of the table's key columns. Defaults to [], indicating no key columns. Supports up to 4 columns.

  • SelectedColumns extends Readonly<SelectionColumn<DB, TB>[]> | ["*"] = ["*"]

    Columns to return from selection queries. Defaults to ['*'], returning all columns. May specify aliases.

  • SelectedObject = SelectedRow<DB, TB, SelectedColumns extends ["*"]
        ? never
        : SelectedColumns[number], SelectedColumns>

    Type of objects returned by select queries.

  • InsertedObject = Insertable<DB[TB]>

    Type of objects inserted into the table.

  • UpdatingObject = Updateable<DB[TB]>

    Type of objects used to update rows of the table.

  • ReturnCount = bigint

  • InsertReturnColumns extends Readonly<SelectionColumn<DB, TB>[]> | ["*"] = Readonly<KeyColumns>

    Columns to return from the table on insert queries that return columns. ['*'] returns all columns; [] returns none. May specify aliases. Defaults to KeyColumns.

  • UpdateReturnColumns extends Readonly<SelectionColumn<DB, TB>[]> | ["*"] = []

    Columns to return from the table on update queries that return columns. ['*'] returns all columns; [] returns none and is the default. May specify aliases.

  • InsertReturn = InsertReturnColumns extends ["*"]
        ? Selectable<DB[TB]>
        : Selection<DB, TB, InsertReturnColumns[number]>

    Type returned from inserts. Defaults to an object whose properties are the columns of InsertReturnColumns.

  • UpdateReturn = UpdateReturnColumns extends ["*"]
        ? Selectable<DB[TB]>
        : Selection<DB, TB, UpdateReturnColumns[number]>

    Type returned from updates. Defaults to an object whose properties are the columns of UpdateReturnColumns.

Hierarchy

Properties

countTransform?: ((count) => ReturnCount)

Type declaration

    • (count): ReturnCount
    • Transformation to apply to bigint count results indicating the number of rows affected, before returning the count to the client. count is the count returned by the query.

      Parameters

      • count: bigint

      Returns ReturnCount

insertReturnTransform?: ((source, returns) => InsertReturn)

Type declaration

    • (source, returns): InsertReturn
    • Transformation to apply to column values returned from inserts before returning values to the client. When inferring type parameters, specify a type for the source parameter. source is the object that was provided for insertion, and returns are the values returned from the insert.

      Parameters

      • source: InsertedObject
      • returns: InsertReturnColumns extends []
            ? never
            : SelectedRow<DB, TB, InsertReturnColumns extends ["*"]
                ? never
                : InsertReturnColumns[number], InsertReturnColumns>

      Returns InsertReturn

insertTransform?: ((source, columns) => Insertable<DB[TB]>)

Type declaration

    • (source, columns): Insertable<DB[TB]>
    • Transformation to apply to inserted objects before insertion. source is the object provided for insertion. Only the columns in columns will actually be inserted, with [*] indicating all columns.

      Parameters

      • source: InsertedObject
      • columns: ["*"] | readonly (NonNullableInsertKeys<DB[TB]> | NullableInsertKeys<DB[TB]>)[]

      Returns Insertable<DB[TB]>

selectTransform?: ((row) => SelectedObject)

Type declaration

    • (row): SelectedObject
    • Transformation to apply to selected objects after retrieval from the database and before returning to the client. row is the selected row, as returned by the Kysely query.

      Parameters

      • row: SelectedRow<DB, TB, SelectedColumns extends ["*"]
            ? never
            : SelectedColumns[number], SelectedColumns>

      Returns SelectedObject

updateReturnTransform?: ((source, returns) => UpdateReturn)

Type declaration

    • (source, returns): UpdateReturn
    • Transformation to apply to column values returned from updates before returning values to the client. When inferring type parameters, specify a type for the source parameter. source is the object that contained the valiues with which the table row was updated, and returns are the values returned from the update.

      Parameters

      • source: UpdatingObject
      • returns: UpdateReturnColumns extends []
            ? never
            : SelectedRow<DB, TB, UpdateReturnColumns extends ["*"]
                ? never
                : UpdateReturnColumns[number], UpdateReturnColumns>

      Returns UpdateReturn

updateTransform?: ((source, columns) => Updateable<DB[TB]>)

Type declaration

    • (source, columns): Updateable<DB[TB]>
    • Transformation to apply to objects provided for updating rows. source is the object containing the values which which to update the table row. Only the columns in columns will actually be updated, with [*] indicating all columns.

      Parameters

      • source: UpdatingObject
      • columns: ["*"] | readonly UpdateKeys<DB[TB]>[]

      Returns Updateable<DB[TB]>

Generated using TypeDoc