mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
Improve asDrizzleTable()
types (#10882)
This commit is contained in:
parent
22d00865cf
commit
cf58d1ed56
3 changed files with 18 additions and 2 deletions
7
.changeset/angry-lemons-tie.md
Normal file
7
.changeset/angry-lemons-tie.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
"@astrojs/db": patch
|
||||
---
|
||||
|
||||
Improves the typing of the `asDrizzleTable()` utility
|
||||
|
||||
Fixes a type error when passing the output of `defineTable()` to the utility and returns a more detailed type inferred from the columns of the passed table config.
|
|
@ -8,7 +8,7 @@ import {
|
|||
sqliteTable,
|
||||
text,
|
||||
} from 'drizzle-orm/sqlite-core';
|
||||
import { type DBColumn, type DBTable } from '../core/types.js';
|
||||
import type { DBColumn, DBTable } from '../core/types.js';
|
||||
import { type SerializedSQL, isSerializedSQL } from './types.js';
|
||||
import { pathToFileURL } from './utils.js';
|
||||
|
||||
|
|
|
@ -1,2 +1,11 @@
|
|||
export { defineDbIntegration } from './core/utils.js';
|
||||
export { asDrizzleTable } from './runtime/index.js';
|
||||
import { tableSchema } from './core/schemas.js';
|
||||
import type { ColumnsConfig, TableConfig } from './core/types.js';
|
||||
import { type Table, asDrizzleTable as internal_asDrizzleTable } from './runtime/index.js';
|
||||
|
||||
export function asDrizzleTable<
|
||||
TableName extends string = string,
|
||||
TColumns extends ColumnsConfig = ColumnsConfig,
|
||||
>(name: TableName, tableConfig: TableConfig<TColumns>) {
|
||||
return internal_asDrizzleTable(name, tableSchema.parse(tableConfig)) as Table<TableName, TColumns>;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue