just_database 1.3.0
just_database: ^1.3.0 copied to clipboard
A pure-Dart SQL database engine.
Changelog #
1.3.0 - 2026-03-19 #
Added — Web Persistence (OPFS + IndexedDB) #
- OPFS Web Worker persistence — databases opened with
persist: trueon web now survive page reloads. A dedicated Web Worker runs the SQL engine against the Origin Private File System using synchronousFileSystemSyncAccessHandle, keeping the main thread free. - Write-Ahead Log (WAL) — all mutations are journalled to a separate OPFS file before being applied, providing crash-safe durability. Auto-checkpoint triggers at 1 MB or 1 000 entries.
- IndexedDB fallback — when OPFS or Web Workers are unavailable (older browsers, cross-origin iframes), the engine automatically falls back to IndexedDB snapshot persistence on the main thread.
- In-memory last resort — if neither OPFS nor IndexedDB is available, the database runs in memory only (same as 1.2.0 behaviour).
WebStorageBackendenum —opfsWorker,indexedDb,memory. Indicates which backend was selected at runtime.storageBackendgetter onJustDatabase(web only) — returns the activeWebStorageBackend.DatabaseSerializerutility (lib/src/serialization.dart) — extracted encode / decode helpers shared by native file persistence and the web layer.- 8 new files under
lib/src/web/:opfs_support.dart,opfs_storage.dart,wal_manager.dart,opfs_persistence.dart,idb_persistence.dart,worker_protocol.dart,database_worker.dart,worker_client.dart. database_native.dart/database_web.dart—database.dartis now a conditional export gateway (dart.library.js_interop), matching the existing pattern used by persistence and backup.
Changed #
webpackage promoted from transitive to direct dependency (^1.1.0).persistence_web.dartnow delegates toOpfsPersistenceorIdbPersistenceinstead of being a no-op stub.
1.2.0 - 2026-03-14 #
Added — Web & WASM Support #
- Web (JS) and Web (WASM) platform targets —
just_databasenow compiles and runs on all Flutter web targets without modification. persistence_native.dart/persistence_web.dart— persistence implementation split into a native file (dart:io+path_provider+encrypt) and a web/WASM no-op stub. The publicpersistence.dartis now a conditional export gateway:dart.library.js_interopselects the stub on both JS-web and WASM.backup_native.dart/backup_web.dart— same conditional export pattern forBackupManager. In-memory methods (exportSql,importSql,exportJson,importJson) are fully functional on web. File helpers (backupToFile,restoreFromFile,backupToJsonFile,restoreFromJsonFile) throwUnsupportedErroron web/WASM with a clear message.platforms:declarations added topubspec.yaml— explicitly listsandroid,ios,linux,macos,web, andwindowsso pub.dev renders the platform badge matrix correctly.SecureKeyManagerworks transparently on web/WASM — key material is stored viajust_storage ^1.1.2which uses browserlocalStorageon web.
Changed #
- Conditional export guard changed from
dart.library.htmltodart.library.js_interop.dart.library.htmlevaluates tofalseunder WASM, causing the native (dart:io) implementation to be selected incorrectly.dart.library.js_interopistrueon both JS-web and WASM. just_storagedependency bumped to^1.1.2(WASM-ready; usespackage:web).
1.1.0 - 2026-02-23 #
Added — Secure Mode (AES-256-GCM encryption at rest) #
DatabaseMode.secure— new database mode that encrypts every page written to disk with AES-256-GCM and a per-save random IV. In-memory access is unaffected; encryption is applied only during persistence.SecureKeyManager— new public class inlib/src/core/secure_key_manager.dart(re-exported from the barrel) that manages the AES-256 key lifecycle:resolveKey({dbName, password})— derives a 256-bit key from a user password via PBKDF2-HMAC-SHA256 (100 000 iterations, 16-byte random salt). The salt is generated once, stored inJustSecureStorage, and retrieved on every subsequent call. The password is never written to disk.clearSalt({dbName})— deletes the persisted salt for a database (use before deleting or resetting an encrypted database).resolveAutoKey({dbName})— generates a cryptographically random 32-byte key withRandom.secure(), stores it inJustSecureStorage, and returns it on every subsequent call. No user interaction required.clearAutoKey({dbName})— deletes the auto-managed key for a database.
just_storagecompanion package added as a dependency — providesJustSecureStorage(AES-256-GCM encrypted key-value store) used bySecureKeyManager.encrypt ^5.0.3andcrypto ^3.0.3added as direct dependencies.
Changed — Internal #
class Row(inlib/src/storage/row.dart) renamed toDatabaseRowto avoid shadowing Flutter'sRowwidget. All internal references updated acrosstable.dart,index.dart,executor.dart, andbackup.dart.- All UI import sites that previously had
hide Rowdirectives have been cleaned up.
1.0.0 - 2026-02-20 #
Added — Core Engine #
- Triggers —
BEFORE/AFTERINSERT,UPDATE,DELETE;INSTEAD OFon views;NEW/OLDrow references;WHENclause; multi-statementBEGIN ENDbodies - Views —
CREATE VIEW,DROP VIEW,SELECTagainst views,INSTEAD OFtriggers on views - Transactions (WAL) —
BEGIN [DEFERRED|IMMEDIATE],COMMIT,ROLLBACK,SAVEPOINT,RELEASE SAVEPOINT,ROLLBACK TO SAVEPOINT;transaction()helper with automatic rollback on error - Spatial / R-tree indexes —
Point,BoundingBox,Polygongeometry types;ST_MAKEPOINT,ST_X,ST_Y,ST_DISTANCE,ST_WITHIN,ST_INTERSECTS,ST_CONTAINS,ST_BBOX;CREATE SPATIAL INDEX; quadratic-split R-tree - Query-optimization hints — inline comment hints:
/*+ INDEX(t idx) */,/*+ NO_INDEX */,/*+ FULL_SCAN */,/*+ FORCE_INDEX(idx) */ - Backup & Restore —
exportSql()full SQL dump;importSql()restore;exportJson()/importJson()JSON snapshot;backupToFile/restoreFromFile - Schema Migrations —
SqlMigration(up/down SQL),CallbackMigration(Dart callbacks),MigrationRunnerwith versioned apply/rollback, SHA-256 checksum validation,status()report, persistent_migrationstracking table - Performance Benchmarking —
DatabaseBenchmark(8-op standard suite),BenchmarkSuite(custom suites),QueryStats(avg/min/max/p95/p99/ops-per-sec), configurable warm-up + seed-row count
Added — ORM Layer #
DbRecord— abstract base class; holds auto-managedid; forcestoMap()DbColumn— typed column builder:.integer(),.text(),.real(),.boolean(),.datetime(),.blob()withnotNull,unique,defaultValueDbTable<T>— generic type-safe table accessor; overridetableName,columns,fromRow()to get full CRUD:- DDL:
createTable(),dropTable(),createTableSql() - Insert:
insert()(returns saved record withid),insertAll()(transactional) - Select:
findAll(),findById(),findWhere(),findFirst(),count() - Update:
update(),updateWhere() - Delete:
deleteById(),deleteWhere(),deleteAll() - Raw:
rawQuery()
- DDL:
DbTableException— typed error for all ORM failures
Added — Admin UI #
- Benchmark tab — standard suite runner + custom single-query benchmark; throughput bars, p95/p99 stat cards, copy-to-clipboard results
- Insert Row tab — dynamic form driven by the live table schema; per-column input types (text, number, boolean switch, date picker); inline validation; success/error feedback
- Settings tab redesigned — live DB stats grid (tables/views/rows/triggers/indexes/size), engine-feature reference tiles, About card with version + license + repo
Added — public API on JustDatabase #
runStandardBenchmark({rowCount, warmup, iterations})Future<BenchmarkSuiteResult>benchmarkQuery(label, sql, {warmup, iterations})Future<QueryStats>triggerNamesgetter —List<String>viewNamesgetter —List<String>indexNamesForTable(String)—List<String>totalRowsgetter —intestimatedSizeBytesgetter —int
Added — version constant #
kJustDatabaseVersionconstant inlib/src/version.dart
Fixed (from 0.0.1) #
HAVINGclause with aggregate functions now works correctlyALTER TABLE RENAME COLUMNfully removes old column references- Subqueries now support correlated patterns and
INclauses - R-tree spatial index quadratic split algorithm correctness
Changed #
- 141 tests passing (69 original + 72 new feature tests)
- Admin UI tabs: Databases Schema Insert Query Benchmark Settings
Known Limitations #
- No
FULL OUTER JOIN(INNER, LEFT, RIGHT are supported) - No
CHECKconstraints - No recursive CTEs (
WITH RECURSIVE) BLOBcolumns accept hex-string values in the Insert UI