query.d.cts 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { entityKind } from "../../entity.cjs";
  2. import { QueryPromise } from "../../query-promise.cjs";
  3. import { type BuildQueryResult, type DBQueryConfig, type TableRelationalConfig, type TablesRelationalConfig } from "../../relations.cjs";
  4. import type { RunnableQuery } from "../../runnable-query.cjs";
  5. import type { Query, SQLWrapper } from "../../sql/sql.cjs";
  6. import type { KnownKeysOnly } from "../../utils.cjs";
  7. import type { SQLiteDialect } from "../dialect.cjs";
  8. import type { PreparedQueryConfig, SQLitePreparedQuery, SQLiteSession } from "../session.cjs";
  9. import type { SQLiteTable } from "../table.cjs";
  10. export type SQLiteRelationalQueryKind<TMode extends 'sync' | 'async', TResult> = TMode extends 'async' ? SQLiteRelationalQuery<TMode, TResult> : SQLiteSyncRelationalQuery<TResult>;
  11. export declare class RelationalQueryBuilder<TMode extends 'sync' | 'async', TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig, TFields extends TableRelationalConfig> {
  12. protected mode: TMode;
  13. protected fullSchema: Record<string, unknown>;
  14. protected schema: TSchema;
  15. protected tableNamesMap: Record<string, string>;
  16. protected table: SQLiteTable;
  17. protected tableConfig: TableRelationalConfig;
  18. protected dialect: SQLiteDialect;
  19. protected session: SQLiteSession<'async', unknown, TFullSchema, TSchema>;
  20. static readonly [entityKind]: string;
  21. constructor(mode: TMode, fullSchema: Record<string, unknown>, schema: TSchema, tableNamesMap: Record<string, string>, table: SQLiteTable, tableConfig: TableRelationalConfig, dialect: SQLiteDialect, session: SQLiteSession<'async', unknown, TFullSchema, TSchema>);
  22. findMany<TConfig extends DBQueryConfig<'many', true, TSchema, TFields>>(config?: KnownKeysOnly<TConfig, DBQueryConfig<'many', true, TSchema, TFields>>): SQLiteRelationalQueryKind<TMode, BuildQueryResult<TSchema, TFields, TConfig>[]>;
  23. findFirst<TSelection extends Omit<DBQueryConfig<'many', true, TSchema, TFields>, 'limit'>>(config?: KnownKeysOnly<TSelection, Omit<DBQueryConfig<'many', true, TSchema, TFields>, 'limit'>>): SQLiteRelationalQueryKind<TMode, BuildQueryResult<TSchema, TFields, TSelection> | undefined>;
  24. }
  25. export declare class SQLiteRelationalQuery<TType extends 'sync' | 'async', TResult> extends QueryPromise<TResult> implements RunnableQuery<TResult, 'sqlite'>, SQLWrapper {
  26. private fullSchema;
  27. private schema;
  28. private tableNamesMap;
  29. private tableConfig;
  30. private dialect;
  31. private session;
  32. private config;
  33. static readonly [entityKind]: string;
  34. readonly _: {
  35. readonly dialect: 'sqlite';
  36. readonly type: TType;
  37. readonly result: TResult;
  38. };
  39. constructor(fullSchema: Record<string, unknown>, schema: TablesRelationalConfig, tableNamesMap: Record<string, string>,
  40. /** @internal */
  41. table: SQLiteTable, tableConfig: TableRelationalConfig, dialect: SQLiteDialect, session: SQLiteSession<'sync' | 'async', unknown, Record<string, unknown>, TablesRelationalConfig>, config: DBQueryConfig<'many', true> | true, mode: 'many' | 'first');
  42. prepare(): SQLitePreparedQuery<PreparedQueryConfig & {
  43. type: TType;
  44. all: TResult;
  45. get: TResult;
  46. execute: TResult;
  47. }>;
  48. private _toSQL;
  49. toSQL(): Query;
  50. execute(): Promise<TResult>;
  51. }
  52. export declare class SQLiteSyncRelationalQuery<TResult> extends SQLiteRelationalQuery<'sync', TResult> {
  53. static readonly [entityKind]: string;
  54. sync(): TResult;
  55. }