@variablesoftware/mock-d1
Version:
🎛️🗂️🧠 Mock D1 Database implementation for testing Cloudflare Workers
20 lines (19 loc) • 891 B
TypeScript
/**
* @file helpers/mockInjectTableRows.ts
* @description Test-only utility for injecting rows into a mock D1 database table.
* @warning This is for test/mocking purposes only and should not be used in production code.
*/
import type { MockD1TableColumn } from '../types/MockD1Database.js';
/**
* Injects rows into a table in the mock D1 database (test helper only).
* Requires explicit columns (no inference from data).
* Throws if extra columns are present in injected rows.
* @param db - The database Map.
* @param tableName - The table name.
* @param columns - The table schema columns (explicit, never inferred).
* @param rows - The rows to inject.
*/
export declare function injectTableRows(db: Map<string, {
rows: Record<string, unknown>[];
columns: MockD1TableColumn[];
}>, tableName: string, columns: MockD1TableColumn[], rows: Record<string, unknown>[]): void;