driver.d.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { sql } from '@vercel/postgres';
  2. import type { Cache } from "../cache/core/cache.js";
  3. import { entityKind } from "../entity.js";
  4. import type { Logger } from "../logger.js";
  5. import { PgDatabase } from "../pg-core/db.js";
  6. import { PgDialect } from "../pg-core/index.js";
  7. import { type RelationalSchemaConfig, type TablesRelationalConfig } from "../relations.js";
  8. import { type DrizzleConfig } from "../utils.js";
  9. import { type VercelPgClient, type VercelPgQueryResultHKT, VercelPgSession } from "./session.js";
  10. export interface VercelPgDriverOptions {
  11. logger?: Logger;
  12. cache?: Cache;
  13. }
  14. export declare class VercelPgDriver {
  15. private client;
  16. private dialect;
  17. private options;
  18. static readonly [entityKind]: string;
  19. constructor(client: VercelPgClient, dialect: PgDialect, options?: VercelPgDriverOptions);
  20. createSession(schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined): VercelPgSession<Record<string, unknown>, TablesRelationalConfig>;
  21. }
  22. export declare class VercelPgDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends PgDatabase<VercelPgQueryResultHKT, TSchema> {
  23. static readonly [entityKind]: string;
  24. }
  25. export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends VercelPgClient = typeof sql>(...params: [] | [
  26. TClient
  27. ] | [
  28. TClient,
  29. DrizzleConfig<TSchema>
  30. ] | [
  31. (DrizzleConfig<TSchema> & ({
  32. client?: TClient;
  33. }))
  34. ]): VercelPgDatabase<TSchema> & {
  35. $client: VercelPgClient extends TClient ? typeof sql : TClient;
  36. };
  37. export declare namespace drizzle {
  38. function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): VercelPgDatabase<TSchema> & {
  39. $client: '$client is not available on drizzle.mock()';
  40. };
  41. }