fix(drizzle): expose db.drizzle.$client type

This commit is contained in:
Sasha
2024-10-17 23:35:05 +03:00
parent 9056b9fe9b
commit 4082680099
5 changed files with 16 additions and 6 deletions

View File

@@ -62,7 +62,9 @@ declare module 'payload' {
afterSchemaInit: PostgresSchemaHook[]
beforeSchemaInit: PostgresSchemaHook[]
beginTransaction: (options?: PgTransactionConfig) => Promise<null | number | string>
drizzle: PostgresDB
drizzle: {
$client: Pool
} & PostgresDB
enums: Record<string, GenericEnum>
/**
* An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name

View File

@@ -1,5 +1,4 @@
import type { DrizzleAdapter } from '@payloadcms/drizzle/types'
import type { LibSQLDatabase } from 'drizzle-orm/libsql'
import type { Connect } from 'payload'
import { createClient } from '@libsql/client'

View File

@@ -167,7 +167,9 @@ declare module 'payload' {
extends Omit<Args, 'idType' | 'logger' | 'migrationDir' | 'pool'>,
DrizzleAdapter {
beginTransaction: (options?: SQLiteTransactionConfig) => Promise<null | number | string>
drizzle: LibSQLDatabase
drizzle: { $client: Client } & LibSQLDatabase<
Record<string, GenericRelation | GenericTable> & Record<string, unknown>
>
/**
* An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name
* Used for returning properly formed errors from unique fields

View File

@@ -56,6 +56,9 @@ export type Args = {
}
export type VercelPostgresAdapter = {
drizzle: {
$client: VercelPool
} & PostgresDB
pool?: VercelPool
poolOptions?: Args['pool']
} & BasePostgresAdapter
@@ -67,7 +70,9 @@ declare module 'payload' {
afterSchemaInit: PostgresSchemaHook[]
beforeSchemaInit: PostgresSchemaHook[]
beginTransaction: (options?: PgTransactionConfig) => Promise<null | number | string>
drizzle: PostgresDB
drizzle: {
$client: VercelPool
} & PostgresDB
enums: Record<string, GenericEnum>
/**
* An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name

View File

@@ -21,7 +21,7 @@ import type {
} from 'drizzle-orm/pg-core'
import type { PgTableFn } from 'drizzle-orm/pg-core/table'
import type { Payload, PayloadRequest } from 'payload'
import type { ClientConfig, QueryResult } from 'pg'
import type { ClientConfig, Pool, QueryResult } from 'pg'
import type { extendDrizzleTable, Operators } from '../index.js'
import type { BuildQueryJoinAliases, DrizzleAdapter, TransactionPg } from '../types.js'
@@ -134,7 +134,9 @@ export type BasePostgresAdapter = {
defaultDrizzleSnapshot: DrizzleSnapshotJSON
deleteWhere: DeleteWhere
disableCreateDatabase: boolean
drizzle: PostgresDB
drizzle: {
$client: Pool
} & PostgresDB
dropDatabase: DropDatabase
enums: Record<string, GenericEnum>
execute: Execute<unknown>