darudb 1.1.0
darudb: ^1.1.0 copied to clipboard
An embedded database that keeps an application's data in one local file. The Dart binding of the DaruDB engine.
Changelog #
This package's history. DaruDB keeps a separate changelog for each package it ships, beside that package's own manifest, because the packages version independently.
1.1.0 - 2026-10-09 #
Breaking changes #
- The file format is version 6, the top-level
formatVersion, which earlier releases cannot open. Opening a file of version 5 raises it to version 6 while no other process has it open, so a file this release has opened no longer opens with 1.0, in Dart or in any other language's package. An app that may go back to an earlier release, or that shares its file with a program still on one, such as an app extension, opens withupgradeFormat: false, which also creates new files in version 5, and callsupgradeFormatonce nothing older opens the file.
Added #
- The
upgradeFormatparameter ofDatabase.openandopenAsync, andupgradeFormatandupgradeFormatAsync, which say whether opening raises a file of an older format version, and raise an open one.
Changed #
- An index whose entries for one value come in key order, as a non-unique index's do while the objects' primary keys grow, fills its pages as it goes, where splitting a page in the middle left half of each empty, and so do the branches of every tree. A file of 400,000 sample objects with 14 indexes is 7% smaller for it. Keys in no particular order split pages evenly, as before.
compactandcompactAsyncfirst write again, full, every tree whose pages inserts left part empty, so that the file ends about as small as a backup's copy: the same file compacts to 119 MiB rather than 140 MiB.- File format 6 writes the lengths in a leaf's entries as varints rather than in five bytes. A file of 400,000 sample objects with 14 indexes takes 8% fewer pages, 126 MiB against 138, and compacts to 110 MiB against 119, with reads and writes as fast as before. A file raised from version 5 has only its header rewritten; its leaves take the new layout as writes change them, and
compactrewrites the trees where that saves room. - The native library is built with its loops aligned to 64 bytes, so that where a hot loop lands no longer depends on the rest of the build: in a development build, the position of one loop alone made one-object deferred commits 15% slower. It is about 7% larger for it. The build for 64-bit Arm Windows is the exception, since the compiler cannot write that platform's unwind information for a function with padding inside it.
Fixed #
compactandcompactAsyncno longer grow the file when a value in an overflow run near the file's end finds no run of free pages below to move into. The run stays where it is, and a round of moves that would grow the file is dropped.- The README and the guide name Flutter 3.38.1 as the oldest release the package installs on, where they said 3.38. Flutter 3.38.0 ships a build of Dart 3.10.0 numbered
3.10.0-290.4.beta, which the package'ssdk: ^3.10.0has never accepted. - The package resolves in a Flutter app on Flutter 3.38.1 to 3.44, the oldest releases it supports. It asked for versions of
hooks,code_assetsandnative_toolchain_rustthat needmeta1.19, which those Flutter releases pin lower, soflutter pub getfailed there.
1.0.1 - 2026-10-07 #
Added #
- An example,
example/main.dart, which stores a few objects, finds them by an index in code and as text, changes one, and opens the file again. pub.dev shows it on the package's Example tab.
1.0.0 - 2026-10-05 #
Added #
Database.openopens or creates a database file, with aSchemaof the collectionsdarudb_generatorgenerates from classes annotated@Collection()and@Embedded(), and the optionscreate,pageSize,busyTimeout,cacheSize,key,passwordandpasswordHashing; akeyand apasswordtogether are refused withINVALID_ARGUMENT, here and insalvageandbackup. A file holding an older schema version is migrated in one write transaction, through theMigrations registered for the versions in between, whose functions read the old objects throughMigrationContext.Database.readandDatabase.writerun a function in a transaction;writecommits when it returns, deferred withDurability.deferred, and aborts when it throws.txn.collection(userSchema)gives a collection's objects as the annotated class:get,find,findOneandcountwith a typed query builder whose conditions combine with&,|and~,findTextfor the query language,Database.prepareandfindPrepared, and in a writeinsert,insertMany,put,putMany,updateanddelete.updatetakes a change for each field it sets, made by the field'sset, an embedded object's included, which it replaces whole.Database.sync,Database.close,setKey,setPassword,isEncrypted,pageSize,formatVersionandschemaVersion. Every failure is aDaruExceptionwith the engine's error code.- The
FutureAPI:Database.openAsync,readAsync,writeAsync,syncAsync,closeAsync,setKeyAsyncandsetPasswordAsync, whose transactions give collections ofFuture-returning calls. The engine's work runs on threads of the native library, and the result comes back on the isolate's event loop. The calls of one transaction run in the order they were made; an isolate's asynchronous writes on one file take turns, and a synchronouswrite,syncorcloseon the file while one runs is refused withINVALID_ARGUMENT. - The tools, each with an
Asynctwin:check, the integrity check, which reports every problem in aCheckReport;backup, a copy of the published commit in a new file, under a new data key when it is given akeyor apasswordfor the copy;compact, which makes the file smaller in place; andDatabase.salvage, which rescues what it can of a damaged file into a new one, with a key or a password for an encrypted file. - The build hook downloads the native library for the application's target from the package's GitHub release, and uses it only when its SHA-256 hash is the one
hook/prebuilt.jsonnames, so building an application needs no Rust toolchain. A download is kept in the hook's cache. In a checkout of the repository, which an application gets by depending on the package through git or a path, the hook builds the engine from source withnative_toolchain_rustinstead.