0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-04-07 23:41:43 -05:00

wip: build a table type

This commit is contained in:
bholmesdev 2024-01-24 13:05:39 -05:00 committed by Nate Moore
parent 648b7708ba
commit 3da918166c

View file

@ -180,3 +180,26 @@ export type AstroId<T extends Pick<GeneratedConfig<'string'>, 'tableName'>> = SQ
>;
export type MaybePromise<T> = T | Promise<T>;
export type Table<
T extends DBFields,
TTable extends Pick<GeneratedConfig<'string'>, 'tableName'>,
> = {
[K in keyof T]: T[K]['type'] extends 'boolean'
? AstroBoolean<
TTable & {
name: K;
hasDefault: T[K]['default'];
notNull: !T[K]['optional'];
}
>
: T[K]['type'] extends 'number'
? AstroNumber<T[K]>
: T[K]['type'] extends 'text'
? AstroText<T[K]>
: T[K]['type'] extends 'date'
? AstroDate<T[K]>
: T[K]['type'] extends 'json'
? AstroJson<T[K]>
: never;
};