import { DB } from "https://deno.land/x/sqlite@v3.9.1/mod.ts";
Query the database and return all matching rows.
This is equivalent to calling all
on
a prepared query which is then immediately
finalized.
The type parameter R
may be supplied by
the user to indicated the type for the rows returned
by the query. Notice that the user is responsible
for ensuring the correctness of the supplied type.
To avoid SQL injection, user-provided values should always be passed to the database through a query parameter.
See QueryParameterSet
for documentation on
how values can be bound to SQL statements.
See QueryParameter
for documentation on how
values are returned from the database.
Examples
const rows = db.query<[string, number]>("SELECT name, age FROM people WHERE city = ?", [city]);
// rows = [["Peter Parker", 21], ...]
const rows = db.query<[string, number]>(
"SELECT name, age FROM people WHERE city = :city",
{ city },
);
// rows = [["Peter Parker", 21], ...]
Parameters
optional
params: QueryParameterSet