Documentation
    Preparing search index...

    Interface CustomTypeParams<T>

    interface CustomTypeParams<T extends CustomTypeValues> {
        dataType: (
            config:
                | T["config"]
                | (Equal<T["configRequired"], true> extends true ? never : undefined),
        ) => string;
        fromDriver?: (value: T["driverData"]) => T["data"];
        toDriver?: (value: T["data"]) => SQL<unknown> | T["driverData"];
    }

    Type Parameters

    Index

    Properties

    dataType: (
        config:
            | T["config"]
            | (Equal<T["configRequired"], true> extends true ? never : undefined),
    ) => string

    Database data type string representation, that is used for migrations

    `jsonb`, `text`
    

    If database data type needs additional params you can use them from config param

    `varchar(256)`, `numeric(2,3)`
    

    To make config be of specific type please use config generic in CustomTypeValues

    Usage example

      dataType() {
    return 'boolean';
    },

    Or

      dataType(config) {
    return typeof config.length !== 'undefined' ? `varchar(${config.length})` : `varchar`;
    }
    fromDriver?: (value: T["driverData"]) => T["data"]

    Optional mapping function, that is responsible for data mapping from database to JS/TS code

    For example, when using timestamp we need to map string Date representation to JS Date

    fromDriver(value: string): Date {
    return new Date(value);
    },
    toDriver?: (value: T["data"]) => SQL<unknown> | T["driverData"]

    Optional mapping function, between user input and driver

    For example, when using jsonb we need to map JS/TS object to string before writing to database

    toDriver(value: TData): string {
    return JSON.stringify(value);
    }