mysql-with-kysely
Version:
Use MySQL with kysely
27 lines (26 loc) • 1.28 kB
TypeScript
import { ColumnType, Generated, Insertable, Kysely, Selectable } from 'kysely';
export declare type WithPkId<Schema> = {
id: Generated<string>;
} & Omit<Schema, 'id'>;
declare type DataLifecycleType = ColumnType<Date, Date | undefined, Date | undefined>;
declare type DataLifecycleTracker = {
created_at: DataLifecycleType;
updated_at: DataLifecycleType;
};
export declare type WithDataLifecycleTracker<Schema> = DataLifecycleTracker & Omit<Schema, 'created_at' | 'updated_at'>;
export declare type WithSchema<Schema> = WithPkId<WithDataLifecycleTracker<Schema>>;
export declare type toSelectableSchema<Database> = {
[key in keyof Database]: Omit<Selectable<Database[key]>, 'created_at' | 'updated_at'>;
};
export declare type toFullSelectableSchema<Database> = {
[key in keyof Database]: Selectable<Database[key]>;
};
export declare type toInsertableSchema<Database> = {
[key in keyof Database]: Insertable<Database[key]>;
};
export declare class MySqlWithKysely<Database> extends Kysely<Database> {
raw<T>(rawSql: string): import("kysely").RawBuilder<T>;
sql<T>(rawSql: TemplateStringsArray, ...parameters: unknown[]): import("kysely").RawBuilder<T>;
}
export declare const queryBuilder: <Database>() => MySqlWithKysely<Database>;
export {};