@variablesoftware/mock-d1
Version:
🎛️🗂️🧠 Mock D1 Database implementation for testing Cloudflare Workers
37 lines (36 loc) • 1.21 kB
TypeScript
import type { D1TableData } from "../../types/MockD1Database";
/**
* Handles INSERT INTO <table> (...) VALUES (...) statements for the mock D1 engine.
* Inserts a new row into the specified table using the provided bind arguments.
*
* @param sql - The SQL INSERT statement string.
* @param db - The in-memory database map.
* @param bindArgs - The named bind arguments for the statement.
* @returns An object representing the result of the INSERT operation.
* @throws If the SQL statement is malformed or the column/bind count does not match.
*/
export declare function handleInsert(sql: string, db: Map<string, D1TableData>, bindArgs?: Record<string, unknown>): {
success: boolean;
results: never[];
meta: {
changes: number;
rows_written: number;
last_row_id: number;
duration?: undefined;
size_after?: undefined;
rows_read?: undefined;
changed_db?: undefined;
};
} | {
success: boolean;
results: never[];
meta: {
duration: number;
size_after: number;
rows_read: number;
rows_written: number;
last_row_id: number;
changed_db: boolean;
changes: number;
};
};