-
Notifications
You must be signed in to change notification settings - Fork 258
/
d1.d.ts
41 lines (36 loc) · 1.08 KB
/
d1.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
interface D1Meta {
duration: number;
size_after: number;
rows_read: number;
rows_written: number;
last_row_id: number;
changed_db: boolean;
changes: number;
}
interface D1Response {
success: true;
meta: D1Meta & Record<string, unknown>;
error?: never;
}
type D1Result<T = unknown> = D1Response & {
results: T[];
}
interface D1ExecResult {
count: number;
duration: number;
}
declare abstract class D1Database {
prepare(query: string): D1PreparedStatement;
dump(): Promise<ArrayBuffer>;
batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
exec(query: string): Promise<D1ExecResult>;
}
declare abstract class D1PreparedStatement {
bind(...values: unknown[]): D1PreparedStatement;
first<T = unknown>(colName: string): Promise<T | null>;
first<T = Record<string, unknown>>(): Promise<T | null>;
run(): Promise<D1Response>;
all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
raw<T = unknown[]>(options: {columnNames: true}): Promise<[string[], ...T[]]>;
raw<T = unknown[]>(options?: {columnNames?: false}): Promise<T[]>;
}