d1-driver
Version:
🌤️ Cloudflare D1 External Fetch Compatible Driver
129 lines (128 loc) • 3.21 kB
TypeScript
export declare class D1 {
private accountId;
private apiKey;
constructor(accountId: string, apiKey: string);
list(params?: {
name?: string;
page?: number;
per_page?: number;
}): Promise<{
success: boolean;
errors: {
code: string;
message: string;
}[];
messages: {
code: string;
message: string;
}[];
result: {
created_at: string;
name: string;
uuid: string;
version: string;
}[];
result_info: {
count: number;
page: number;
per_page: number;
total_count: number;
};
}>;
create(name: string): Promise<{
success: boolean;
errors: {
code: string;
message: string;
}[];
messages: {
code: string;
message: string;
}[];
result: {
created_at: string;
name: string;
uuid: string;
version: string;
} | null;
}>;
delete(uuid: string): Promise<{
success: boolean;
errors: {
code: string;
message: string;
}[];
messages: {
code: string;
message: string;
}[];
result: null;
}>;
get(uuid: string): Promise<{
success: boolean;
errors: {
code: string;
message: string;
}[];
messages: {
code: string;
message: string;
}[];
result: {
created_at: string;
file_size: number;
name: string;
num_tables: number;
uuid: string;
version: string;
};
}>;
query<T extends Record<string, any>>(uuid: string, sql: string, params?: (string | number)[]): Promise<{
success: boolean;
errors: {
code: string;
message: string;
}[];
messages: {
code: string;
message: string;
}[];
result: {
success: boolean;
results: T[];
meta: {
changed_db: boolean;
changes: number;
duration: number;
last_row_id: number;
rows_read: number;
rows_written: number;
size_after: number;
};
}[];
}>;
raw(uuid: string, sql: string, params?: (string | number)[]): Promise<{
success: boolean;
errors: {
code: string;
message: string;
}[];
messages: {
code: string;
message: string;
}[];
result: {
success: boolean;
results: Record<string, unknown>[];
meta: {
changed_db: boolean;
changes: number;
duration: number;
last_row_id: number;
rows_read: number;
rows_written: number;
size_after: number;
};
}[];
}>;
}