|
1 |
| -declare interface ChdbModule { |
2 |
| - Execute(query: string, format: string): string; |
3 |
| - Session(query: string, format: string, path: string): string; |
4 |
| -} |
5 |
| - |
6 |
| -declare const chdb: ChdbModule; |
| 1 | +/** |
| 2 | + * Executes a query using the chdb addon. |
| 3 | + * |
| 4 | + * @param query The query string to execute. |
| 5 | + * @param format The format for the query result, default is "CSV". |
| 6 | + * @returns The query result as a string. |
| 7 | + */ |
| 8 | +export function query(query: string, format?: string): string; |
7 | 9 |
|
8 |
| -declare interface DB { |
9 |
| - format: string; |
| 10 | +/** |
| 11 | + * Session class for managing queries and temporary paths. |
| 12 | + */ |
| 13 | +export class Session { |
| 14 | + /** |
| 15 | + * The path used for the session. This could be a temporary path or a provided path. |
| 16 | + */ |
10 | 17 | path: string;
|
11 |
| - query(query: string, format?: string): string; |
12 |
| - session(query: string, format?: string, path?: string): string; |
13 |
| -} |
14 | 18 |
|
15 |
| -declare interface DBFactory { |
16 |
| - (format?: string, path?: string): DB; |
17 |
| - new (format?: string, path?: string): DB; |
18 |
| -} |
| 19 | + /** |
| 20 | + * Indicates whether the path is a temporary directory or not. |
| 21 | + */ |
| 22 | + isTemp: boolean; |
| 23 | + |
| 24 | + /** |
| 25 | + * Creates a new session. If no path is provided, a temporary directory is created. |
| 26 | + * |
| 27 | + * @param path Optional path for the session. If not provided, a temporary directory is used. |
| 28 | + */ |
| 29 | + constructor(path?: string); |
19 | 30 |
|
20 |
| -declare const db: DBFactory; |
| 31 | + /** |
| 32 | + * Executes a session-bound query. |
| 33 | + * |
| 34 | + * @param query The query string to execute. |
| 35 | + * @param format The format for the query result, default is "CSV". |
| 36 | + * @returns The query result as a string. |
| 37 | + */ |
| 38 | + query(query: string, format?: string): string; |
21 | 39 |
|
22 |
| -export { chdb, db }; |
| 40 | + /** |
| 41 | + * Cleans up the session, deleting the temporary directory if one was created. |
| 42 | + */ |
| 43 | + cleanup(): void; |
| 44 | +} |
0 commit comments