driver.d.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { Database } from 'bun:sqlite';
  2. import { entityKind } from "../entity.js";
  3. import { BaseSQLiteDatabase } from "../sqlite-core/db.js";
  4. import { type DrizzleConfig } from "../utils.js";
  5. export declare class BunSQLiteDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends BaseSQLiteDatabase<'sync', void, TSchema> {
  6. static readonly [entityKind]: string;
  7. }
  8. type DrizzleBunSqliteDatabaseOptions = {
  9. /**
  10. * Open the database as read-only (no write operations, no create).
  11. *
  12. * Equivalent to {@link constants.SQLITE_OPEN_READONLY}
  13. */
  14. readonly?: boolean;
  15. /**
  16. * Allow creating a new database
  17. *
  18. * Equivalent to {@link constants.SQLITE_OPEN_CREATE}
  19. */
  20. create?: boolean;
  21. /**
  22. * Open the database as read-write
  23. *
  24. * Equivalent to {@link constants.SQLITE_OPEN_READWRITE}
  25. */
  26. readwrite?: boolean;
  27. };
  28. export type DrizzleBunSqliteDatabaseConfig = ({
  29. source?: string;
  30. } & DrizzleBunSqliteDatabaseOptions) | string | undefined;
  31. export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends Database = Database>(...params: [] | [
  32. TClient | string
  33. ] | [
  34. TClient | string,
  35. DrizzleConfig<TSchema>
  36. ] | [
  37. (DrizzleConfig<TSchema> & ({
  38. connection?: DrizzleBunSqliteDatabaseConfig;
  39. } | {
  40. client: TClient;
  41. }))
  42. ]): BunSQLiteDatabase<TSchema> & {
  43. $client: TClient;
  44. };
  45. export declare namespace drizzle {
  46. function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): BunSQLiteDatabase<TSchema> & {
  47. $client: '$client is not available on drizzle.mock()';
  48. };
  49. }
  50. export {};