UNPKG

@variablesoftware/mock-d1

Version:

🎛️🗂️🧠 Mock D1 Database implementation for testing Cloudflare Workers

25 lines (24 loc) 1 kB
import { D1TableData } from "../../types/MockD1Database"; /** * Handles UPDATE <table> SET <col> = :val WHERE <col2> = :val2 statements for the mock D1 engine. * Updates rows in the specified table that match the WHERE clause, setting the given column to the provided value. * * @param sql - The SQL UPDATE 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 UPDATE operation. * @throws If the SQL statement is malformed, required bind arguments are missing, or the table does not exist. */ export declare function handleUpdate(sql: string, db: Map<string, D1TableData>, bindArgs?: Record<string, unknown>): { 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; }; };