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:
parent
648b7708ba
commit
3da918166c
1 changed files with 23 additions and 0 deletions
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue