just_database library
just_database — Pure-Dart SQL database engine for Flutter.
Features:
- Full SQL support: SELECT, INSERT, UPDATE, DELETE, CREATE/DROP/ALTER TABLE
- JOINs: INNER, LEFT, RIGHT
- Aggregates: COUNT, SUM, AVG, MIN, MAX with GROUP BY and HAVING
- 3 concurrency modes: standard, readFast, writeFast
- Optional file persistence via path_provider
- Embeddable admin widget JustDatabaseAdminWidget
- Triggers (BEFORE/AFTER INSERT/UPDATE/DELETE)
- Spatial data (ST_* functions, R-tree index)
- Query optimization hints (/*+ INDEX(...) */)
- Backup/restore (SQL dump + JSON)
- Schema migrations
- Performance benchmarking
- ORM layer (DbTable / DbRecord / DbColumn)
Classes
- AlterTableStatement
- AppliedMigration
- Simple DTO describing a recorded migration.
- AssignmentClause
- AstNode
- BackupManager
- Export and import utilities for backing up and restoring a JustDatabase. All methods are static helpers that operate on the raw table map.
- BeginStatement
-
BEGIN
DEFERRED|IMMEDIATE|EXCLUSIVETRANSACTION|WORK - BenchmarkCase
- A single benchmark test case.
- BenchmarkSuite
- A collection of named benchmark cases that can be run together.
- BenchmarkSuiteResult
- Result from running a full BenchmarkSuite.
- BetweenExpression
- BinaryExpression
- BoundingBox
- A 2D axis-aligned bounding box.
- CallbackMigration
- A migration defined by Dart callback functions.
- ColumnDefinition
- Definition of a single table column.
- ColumnDefinitionNode
- Column definition inside CREATE TABLE or ALTER TABLE ADD COLUMN.
- ColumnReferenceExpression
- CommitStatement
-
COMMIT
TRANSACTION|WORK - ConstraintDefinition
- Constraint definitions for a column.
- CreateIndexStatement
-
CREATE
UNIQUE|SPATIALINDEXIF NOT EXISTSname ON table (col,...) - CreateTableStatement
- CreateTriggerStatement
-
CREATE TRIGGER name {BEFORE|AFTER|INSTEAD OF} {INSERT|UPDATE
OF col,...|DELETE} ON table FOR EACH ROWWHEN (expr)BEGIN stmts END - CreateViewStatement
-
CREATE
OR REPLACEVIEW name AS select_stmt - DatabaseBenchmark
- Pre-built benchmark scenarios for JustDatabase.
- DatabaseInfo
- Summary information about a database (open or persisted).
- DatabaseManager
- Global registry and lifecycle manager for JustDatabase instances.
- DatabaseProvider
- Provider for managing database state and operations in the admin UI.
- DatabaseSnapshot
- A snapshot of a persisted database loaded from disk.
- DatabasesTab
- DbColumn
- Describes a single column in a DbTable.
- DbRecord
- Base class for every record managed by a DbTable.
-
DbTable<
T extends DbRecord> - Type-safe table accessor — extend once per entity to get full CRUD.
- DeleteStatement
- DropIndexStatement
-
DROP INDEX
IF EXISTSnameON table - DropTableStatement
- DropTriggerStatement
-
DROP TRIGGER
IF EXISTSname - DropViewStatement
-
DROP VIEW
IF EXISTSname - Executor
- Executes parsed SQL AST nodes against the in-memory table store.
- Expression
- ForeignKeyConstraintNode
- FunctionCallExpression
- IndexMetadata
- Metadata about an index, tracking its properties and usage.
- InListExpression
- InsertResult
- Result of an INSERT operation.
- InsertStatement
- IsNullExpression
- JoinClause
- JUDatabaseAdminScreen
- JustDatabase
- The main database class. Wraps the storage, SQL engine, and lock manager.
- JustDatabaseAdminWidget
- A self-contained admin widget that can be embedded in any Flutter app.
- LiteralExpression
- LockManager
- Abstract lock manager interface. Controls concurrent access to table resources.
- Migration
- Abstract base class for migrations.
- MigrationResult
- Result for a single migration step.
- MigrationRunner
-
Manages schema versioning and migration execution.
Stores applied versions in a special
_migrationstable. - OrderByClause
- ParenthesizedExpression
- Parser
- Recursive-descent SQL parser. Converts a token list into an Statement AST.
- PersistenceManager
- Handles reading and writing database files to device storage.
- Point
- A 2D point with x and y coordinates.
- Polygon
- A polygon defined by an ordered list of vertices.
- QueryBuilder
- Fluent query builder for convenience wrapping of SQL operations.
- QueryEditorTab
- QueryHint
- QueryResult
- Result of a SQL query or statement execution.
- QueryStats
- Statistics for a single query or operation.
- ReadFastLockManager
- ReleaseStatement
-
RELEASE
SAVEPOINTname - RollbackStatement
-
ROLLBACK
TRANSACTION|WORK[TOSAVEPOINTname] - Row
- A single row in a table.
- RTreeEntry
- Entry stored in the R-tree.
- RTreeIndex
- An in-memory R-tree spatial index using the quadratic split algorithm. Supports insert, delete, bounding-box search, and k-nearest-neighbour query.
- SavepointStatement
- SAVEPOINT name
- SchemaTab
- SelectColumn
- A column reference in a SELECT list (e.g. "u.name AS username").
- SelectStatement
- SettingsTab
- SqlMigration
- A migration defined by raw SQL strings.
- StandardLockManager
- Statement
- SubqueryExpression
- Table
- In-memory table holding rows, a schema, and optional indices.
- TableConstraint
- Table-level constraint (multi-column PRIMARY KEY or UNIQUE).
- TableIndex
- A hash-based index mapping column values to row IDs. Supports both single-column and composite (multi-column) indexes. Used to accelerate WHERE conditions on indexed columns.
- TableLevelConstraintNode
- Represents a table-level constraint (PRIMARY KEY or UNIQUE).
- TableSchema
- Schema definition for a table.
- Token
- A single lexical token.
- UnaryExpression
- UpdateStatement
- WriteFastLockManager
Enums
- AlterActionType
- DatabaseMode
- The concurrency mode for a JustDatabase instance.
- DataType
- The supported SQL data types.
- HintType
- IndexType
- Type of index for tracking its purpose and behavior.
- JoinType
- MigrationStatus
- Status of an individual migration.
- TableConstraintType
- Type of table-level constraint.
- TriggerEvent
- TriggerTiming
Constants
- kJustDatabaseVersion → const String
- The current version of the just_database package.
Functions
-
parseDataType(
String typeName) → DataType - Parses a SQL type name string into a DataType.
Typedefs
-
SeedDatabaseCallback
= Future<
void> Function(JustDatabase db) - Callback type for seeding a database with initial sample data.
Exceptions / Errors
- DbTableException
- Thrown when a DbTable operation fails.
- ExecutorException
- ParseException