JustDatabase class
The main database class. Wraps the storage, SQL engine, and lock manager.
Properties
- encryptionKey → String?
-
The AES-256-GCM encryption key used when mode is DatabaseMode.secure.
nullfor all other modes.final - estimatedSizeBytes → int
-
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- inTransaction → bool
-
Whether a transaction is currently active on this database.
no setter
- isOpen → bool
-
no setter
- mode → DatabaseMode
-
final
- name → String
-
final
- persist → bool
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
tableNames
→ List<
String> -
no setter
- totalRows → int
-
no setter
-
triggerNames
→ List<
String> -
Returns the names of all defined triggers.
no setter
-
viewNames
→ List<
String> -
Returns the names of all defined views.
no setter
Methods
-
beginTransaction(
{String? mode}) → Future< QueryResult> - Begins a transaction. Returns an error result if one is already active.
-
benchmarkQuery(
String label, String sql, {int warmup = 3, int iterations = 50}) → Future< QueryStats> -
Benchmarks a single SQL query by running it
iterationstimes. -
close(
) → Future< void> -
commit(
) → Future< QueryResult> - Commits the current transaction.
-
execute(
String sql) → Future< QueryResult> - Executes DDL or DML statements (CREATE, INSERT, UPDATE, DELETE, DROP, ALTER).
-
from(
String tableName) → QueryBuilder -
Returns a QueryBuilder for fluent query construction on
tableName. -
getTableSchema(
String name) → TableSchema? -
indexNamesForTable(
String tableName) → List< String> - Returns the names of all indexes on a named table.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
query(
String sql) → Future< QueryResult> - Executes a SELECT statement and returns results.
-
releaseSavepoint(
String name) → Future< QueryResult> - Releases a named savepoint.
-
rollback(
{String? savepoint}) → Future< QueryResult> -
Rolls back the current transaction.
If
savepointis provided, rolls back only to that savepoint. -
runStandardBenchmark(
{int rowCount = 1000, int warmup = 3, int iterations = 50}) → Future< BenchmarkSuiteResult> - Runs the standard benchmark suite against this database.
-
savepoint(
String name) → Future< QueryResult> - Creates a named savepoint within the current transaction.
-
toString(
) → String -
A string representation of this object.
inherited
-
transaction<
T> (Future< T> action(JustDatabase db)) → Future<T> -
Executes
actioninside a transaction, automatically committing on success or rolling back on error.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
open(
String name, {DatabaseMode mode = DatabaseMode.standard, bool persist = true, String? encryptionKey}) → Future< JustDatabase> -
Opens or creates a database.
If
persistis true and a file exists on disk, loads tables from disk.