driver.d.ts 1.9 KB

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