Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit 6cac151

Browse files
authored
Added D1Database and related types (#265)
Co-authored-by: Glen Maddern <[email protected]>
1 parent 38b7e0f commit 6cac151

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

.changeset/violet-tables-appear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudflare/workers-types": minor
3+
---
4+
5+
Added D1 binding types

overrides/d1.d.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
declare type D1Result<T = unknown> = {
2+
results?: T[];
3+
lastRowId: number | null;
4+
changes: number;
5+
duration: number;
6+
error?: string;
7+
};
8+
declare abstract class D1Database {
9+
prepare(query: string): D1PreparedStatement;
10+
dump(): Promise<ArrayBuffer>;
11+
batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
12+
exec<T = unknown>(query: string): Promise<D1Result<T>>;
13+
_send<T = unknown>(
14+
endpoint: string,
15+
query: any,
16+
params: any[]
17+
): Promise<D1Result<T>[] | D1Result<T>>;
18+
}
19+
declare abstract class D1PreparedStatement {
20+
bind(...values: any[]): D1PreparedStatement;
21+
first<T = unknown>(colName?: string): Promise<T>;
22+
run<T = unknown>(): Promise<D1Result<T>>;
23+
all<T = unknown>(): Promise<D1Result<T[]>>;
24+
raw<T = unknown>(): Promise<T[]>;
25+
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)