method

bun.TransactionSQL.file

file<T = any>(
filename: string,
values?: any[] | Record<string, any>
): Query<T>;

Reads a file and runs its contents as a query. The query is lazy: Bun reads the file when the query starts. Pass values as an array if the file uses positional parameters ($1 on PostgreSQL, ? on MySQL). With the SQLite adapter, values may also be an object of named parameters (:name, $name, or @name placeholders). A key works with or without the prefix.

const result = await sql.file("query.sql", [1, 2, 3]);