Package dev.gmitch215.bytebox.durable
Interface SQL
- All Superinterfaces:
org.teavm.jso.JSObject
public interface SQL
extends org.teavm.jso.JSObject
A Durable Object's SQLite database.
Reached through DurableState.sql(java.lang.String, java.lang.Object...). Two things make this different from
D1Database, and both matter: a query here runs synchronously
rather than over a promise, and the object's storage has real transactions.
state.sql("create table if not exists visits (day text primary key, count integer)");
state.sql("insert into visits values (?1, 1) on conflict(day) do update set count = count + 1", day);
long count = state.sql("select count from visits where day = ?1", day).one().get("count").asLong();
The database is private to one Durable Object instance and lives with it. A query counts against that instance's storage rather than an account-level database.
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionasArray()columns()Returns the column names, in the order the query returns them.one()Returns the single row this query answered.rows()Returns every row, read at once.introwsRead()Returns how many rows the query read, which is what the platform bills.intReturns how many rows the query wrote.Methods inherited from interface org.teavm.jso.JSObject
cast
-
Method Details
-
rows
Returns every row, read at once.- Returns:
- every row, read at once
-
one
TSObject one()Returns the single row this query answered.Throws if the query answered no rows or more than one, which is what makes it worth using over reading the first of a list.
- Returns:
- the single row this query answered
-
rowsRead
int rowsRead()Returns how many rows the query read, which is what the platform bills.- Returns:
- how many rows the query read, which is what the platform bills
-
rowsWritten
int rowsWritten()Returns how many rows the query wrote.- Returns:
- how many rows the query wrote
-
columns
Returns the column names, in the order the query returns them.- Returns:
- the column names, in the order the query returns them
-
asArray
TSObject asArray() -
columnNames
TSObject columnNames()
-