import { SQLiteClient } from "https://deno.land/x/denodb@v1.1.0/deps.ts";
Properties
Return the number of rows modified, inserted or
deleted by the most recently completed query.
This corresponds to the SQLite function
sqlite3_changes
.
Get last inserted row id. This corresponds to
the SQLite function sqlite3_last_insert_rowid
.
Before a row is inserted for the first time (since
the database was opened), this returns 0
.
Methods
Close the database. This must be called if the database is no longer used to avoid leaking open file descriptors.
If force is specified, any active PreparedQuery
will be finalized. Otherwise, this throws if there
are active queries.
close
may safely be called multiple
times.
Prepares the given SQL query, so that it can be run multiple times and potentially with different parameters.
If a query will be issued a lot, this is more
efficient than using query
. A prepared
query also provides more control over how
the query is run, as well as access to meta-data
about the issued query.
The returned PreparedQuery
object must be
finalized by calling its finalize
method
once it is no longer needed.
Typing Queries
Prepared query objects accept three type parameters to specify precise types for returned data and query parameters.
The first type parameter R
indicates the tuple type
for rows returned by the query.
The second type parameter O
indicates the record type
for rows returned as entries (mappings from column names
to values).
The third type parameter P
indicates the type this query
accepts as parameters.
Note, that the correctness of those types must be guaranteed by the caller of this function.
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.
Like query
except each row is returned
as an object containing key-value pairs.