driver.d.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { type Pool, type PoolConfig } from 'pg';
  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/dialect.js";
  7. import { type RelationalSchemaConfig, type TablesRelationalConfig } from "../relations.js";
  8. import { type DrizzleConfig } from "../utils.js";
  9. import type { NodePgClient, NodePgQueryResultHKT } from "./session.js";
  10. import { NodePgSession } from "./session.js";
  11. export interface PgDriverOptions {
  12. logger?: Logger;
  13. cache?: Cache;
  14. }
  15. export declare class NodePgDriver {
  16. private client;
  17. private dialect;
  18. private options;
  19. static readonly [entityKind]: string;
  20. constructor(client: NodePgClient, dialect: PgDialect, options?: PgDriverOptions);
  21. createSession(schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined): NodePgSession<Record<string, unknown>, TablesRelationalConfig>;
  22. }
  23. export declare class NodePgDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends PgDatabase<NodePgQueryResultHKT, TSchema> {
  24. static readonly [entityKind]: string;
  25. }
  26. export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends NodePgClient = Pool>(...params: [
  27. TClient | string
  28. ] | [
  29. TClient | string,
  30. DrizzleConfig<TSchema>
  31. ] | [
  32. DrizzleConfig<TSchema> & ({
  33. client: TClient;
  34. } | {
  35. connection: string | PoolConfig;
  36. })
  37. ]): NodePgDatabase<TSchema> & {
  38. $client: NodePgClient extends TClient ? Pool : TClient;
  39. };
  40. export declare namespace drizzle {
  41. function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): NodePgDatabase<TSchema> & {
  42. $client: '$client is not available on drizzle.mock()';
  43. };
  44. }