Flutter database for super-fast Dart object persistence
APACHE-2.0 License
Bot releases are visible (Hide)
Note: this release includes the same versions of the Android library and ObjectBox pod as release 4.0.0.
See update instructions there.
ObjectWithScore
and IdWithScore
used by the new find with score Query
methods. #637
vectorsearch_cities
Dart Native example application.Note: this release includes the same versions of the Android library and ObjectBox pod as release 4.0.0.
See update instructions there.
Published by greenrobot-team 5 months ago
To upgrade to this major release run flutter pub upgrade objectbox --major-versions
(or for Dart Native apps dart pub upgrade objectbox --major-versions
).
ObjectBox now supports Vector Search to enable efficient similarity searches.
This is particularly useful for AI/ML/RAG applications, e.g. image, audio, or text similarity. Other use cases include semantic search or recommendation engines.
Create a Vector (HNSW) index for a floating point vector property. For example, a City
with a location vector:
@Entity()
class City {
@HnswIndex(dimensions: 2)
@Property(type: PropertyType.floatVector)
List<double>? location;
}
Perform a nearest neighbor search using the new nearestNeighborsF32(queryVector, maxResultCount)
query condition and the new "find with scores" query methods (the score is the distance to the
query vector). For example, find the 2 closest cities:
final madrid = [40.416775, -3.703790];
final query = box
.query(City_.location.nearestNeighborsF32(madrid, 2))
.build();
final closest = query.findWithScores()[0].object;
For an introduction to Vector Search, more details and other supported languages see the
Vector Search documentation.
io.objectbox:objectbox-android-objectbrowser:4.0.0
in android/app/build.gradle
.pod repo update
and pod update ObjectBox
.SyncCredentials.userAndPassword()
.SyncCredentials
from constructors to static methods. This should not require any changesNote: this release includes the same versions of the Android library and ObjectBox pod as release 2.5.0. See update instructions there.
Support creating file-less in-memory databases, for example for caching or testing. To create one
pass an in-memory identifier together with Store.inMemoryPrefix
as the directory
:
final inMemoryStore =
Store(getObjectBoxModel(), directory: "${Store.inMemoryPrefix}test-db");
See the Store
documentation for details.
Add Store.removeDbFiles()
to conveniently delete database files or an in-memory database.
Add Store.dbFileSize()
to get the size in bytes of the main database file or memory occupied by
an in-memory database.
Add relationCount()
query condition to match objects that have a certain number of related
objects pointing to them. E.g. Customer_.orders.relationCount(2)
will match all customers with
two orders. Customer_.orders.relationCount(0)
will match all customers with no associated order.
This can be useful to find objects where the relation was dissolved, e.g. after the related object
was removed.
Support for setting a maximum data size via the maxDataSizeInKB
property when building a Store
.
This is different from the existing maxDBSizeInKB
property in that it is possible to remove data
after reaching the limit and continue to use the database. See the Store
documentation for more
details.
For DateTime
properties new convenience query conditions are generated that accept DateTime
and auto-convert to milliseconds (or nanoseconds for @Property(type: PropertyType.dateNano)
) #287
// For example instead of:
Order_.date.between(DateTime(2024, 1).millisecondsSinceEpoch, DateTime(2024, 2).millisecondsSinceEpoch)
// You can now just write:
Order_.date.betweenMilliseconds(DateTime(2024, 1), DateTime(2024, 2))
When defining a property with a getter and setter instead of a field, support annotating the
getter to configure or ignore the property #392
For example, it is now possible to do this:
@Property(type: PropertyType.date)
@Index()
DateTime get date => TODO;
set date(DateTime value) => TODO;
@Transient()
int get computedValue => TODO;
set computedValue(int value) => TODO;
For Flutter apps: loadObjectBoxLibraryAndroidCompat()
is now called by default when using
openStore()
(effective after re-running flutter pub run build_runner build
). For devices
running Android 6 or older this will pre-load the ObjectBox library in Java to prevent errors when
loading it in Dart.
If your code was calling the compat method manually, remove the call and re-run above command.
Let us know if there are issues with this change in #369!
Avoid conflicts with entity class names in generated code #519
Flutter for Linux/Windows, Dart Native: update to objectbox-c 0.21.0.
Flutter for Android: update to objectbox-android 3.8.0.
If you are using Admin, make sure to
update to io.objectbox:objectbox-android-objectbrowser:3.8.0
in android/app/build.gradle
.
Flutter for iOS/macOS: update to objectbox-swift 1.9.2.
Existing projects may have to run pod repo update
and pod update ObjectBox
.
Fix crash in Flutter plugin when running in debug mode on iOS. #561
Support Flutter projects using Android Gradle Plugin 8. #581
Flutter for Linux/Windows: fix CMake build deprecation warning. #522
Flutter for Linux/Windows, Dart Native: update to objectbox-c 0.20.0.
Flutter for Android: update to objectbox-android 3.7.1.
If you are using Admin, make sure to update to io.objectbox:objectbox-android-objectbrowser:3.7.1
in android/app/build.gradle
.
Notably requires Android 4.4 (API level 19) or higher.
Flutter for iOS/macOS: update to objectbox-swift 1.9.1.
Existing projects may have to run pod repo update
and pod update ObjectBox
.
Notably requires iOS 12.0 and macOS 10.15 or higher.
Sync: add Sync.clientMultiUrls
to work with multiple servers.
In this release objectbox_flutter_libs
and objectbox_sync_flutter_libs
continue to use objectbox-android 3.7.0
and Pod ObjectBox 1.9.0
.
Query support for integer and floating point lists: For integer lists (excluding byte lists)
greater, less and equal are supported on elements of the vector (e.g. "has element greater").
For floating point lists greater and less queries are supported on elements of the vector
(e.g. "has element greater").
A simple example is a shape entity that stores a palette of RGB colors:
@Entity()
class Shape {
@Id()
int id = 0;
// An array of RGB color values that are used by this shape.
Int32List? palette;
}
// Find all shapes that use red in their palette
final query = store.box<Shape>()
.query(Shape_.palette.equals(0xFF0000))
.build();
query.findIds();
query.close();
Queries: all expected results are now returned when using a less-than or less-or-equal condition
for a String property with IndexType.value
. #318
Queries: when combining multiple conditions with OR and adding a condition on a related entity
("link condition") the combined conditions are now properly applied. #546
Update: objectbox-c 0.19.0.
Notably now requires glibc 2.28 or higher (and GLIBCXX_3.4.25); e.g. at least Debian Buster 10
(2019) or Ubuntu 20.04.
Update: objectbox-swift 1.9.0.
Update: objectbox-android 3.7.0.
If you are using Admin, make sure to update to
io.objectbox:objectbox-android-objectbrowser:3.7.0
.
In this release objectbox_flutter_libs
ships with objectbox-android 3.5.1
and ObjectBox pod 1.8.1
.
For Flutter apps running on Android 6 (or older): added loadObjectBoxLibraryAndroidCompat()
to
objectbox_flutter_libs
(and objectbox_sync_flutter_libs
). Use this to fix loading the
ObjectBox library on these devices.
Let us know if this works for you in #369!
We might consider calling this automatically in a future release.
Improve code generator performance if there are many entities with many constructor parameters.
Throw StateError
instead of crashing on closed Box
, Query
and PropertyQuery
.
Export query property classes to make them usable in user code.
Resolve an issue where unexpected data was returned when doing a read operation in an entity constructor or property setter. #550
In this release objectbox_flutter_libs
ships with objectbox-android 3.5.1
and ObjectBox pod 1.8.1
.
Support for integer and floating point lists: store 8-bit, 16-bit, 32-bit and 64-bit integer
lists as well as 32-bit and 64-bit floating point lists (called "vectors" by ObjectBox).
Use a typed_data
class like Int16List
, Uint16List
or Float32List
for large lists, it uses
less memory and CPU. Otherwise just use a Dart number list.
A simple example is a shape entity that stores a palette of RGB colors:
@Entity()
class Shape {
@Id()
int id = 0;
// An array of RGB color values that are used by this shape.
Int32List? palette;
}
This can also be useful to store vector embeddings produced by machine learning:
@Entity()
class ImageEmbedding {
@Id()
int id = 0;
// Link to the actual image, e.g. on Cloud storage
String? url;
// The coordinates computed for this image (vector embedding)
@Property(type: PropertyType.floatVector)
List<double>? coordinates;
}
Note: for queries currently only the isNull
and notNull
conditions are supported.
Changed PropertyType.char
from a 8-bit signed integer to a 16-bit unsigned integer to match the
ObjectBox database type.
Fix put returning an incorrect error message in a rare case.
Require at least Dart SDK 2.18 (shipped with Flutter 3.3.0).
Let Store.awaitQueueCompletion
actually wait on the async queue to become idle. It previously
behaved like Store.awaitQueueSubmitted
.
Fix analysis event send failure breaking the code generator. #542
In this release objectbox_flutter_libs
ships with objectbox-android 3.5.1
and ObjectBox pod 1.8.1
.
To upgrade to this major release run flutter pub upgrade objectbox --major-versions
(or for Dart Native apps dart pub upgrade objectbox --major-versions
).
flutter pub run build_runner build
dart run build_runner build
for Dart Native apps) after updating!Box
:
getAsync
, getManyAsync
, getAllAsync
,putAsync
and putManyAsync
which support objects with relations,putAsync
to putQueuedAwaitResult
,putAndGetAsync
and putAndGetManyAsync
which return a copy of the given objects with newremoveAsync
, removeManyAsync
and removeAllAsync
.Query
APIs: findAsync
, findFirstAsync
, findUniqueAsync
, findIdsAsync
andremoveAsync
.ToOne
and ToMany
across isolates, e.g. when usingstore.runInTransactionAsync
. #340Store.attach
(and Store.fromReference
) do not longer accept a null model, which was notstore.awaitAsyncSubmitted
and awaitAsyncCompletion
toawaitQueueSubmitted
and awaitQueueCompletion
to avoid any mix-up with the new async methods.Store.runIsolated
.In this release objectbox_flutter_libs
ships with objectbox-android 3.5.1
and ObjectBox pod 1.8.1
.
objectbox-android-objectbrowser
dependency to 3.5.1
.We're hiring! 😎 We believe resource-efficient coding is still cool and are looking for a C / C++ developer who shares our sentiment.
Published by greenrobot-team almost 2 years ago
// BEFORE
final query = (box.query()..order(Person_.name)).build();
// AFTER
final query = box.query().order(Person_.name).build();
analyzer
with major version 5. #487.containsElement
, deprecate .contains
condition for List<String>
. #481StorageException
which is a ObjectBoxException
with an errorCode
(a OBX_ERROR
code).DbFullException
instead of ObjectBoxException
with message 10101 Could not put
(errorOBX_ERROR_DB_FULL
).Query.findUnique()
to throw NonUniqueResultException
instead ofUniqueViolationException
if there is more than one result.objectbox-android-objectbrowser
dependency.objectbox-android-objectbrowser
dependency.// coverage:ignore-file
to generated objectbox.g.dart skipping this file from coverage test.analyzer
to v4. #443Query
streams using watch
to highlight it is a single-subscriptionStore.runInTransactionAsync
to run database operations asynchronously in the background (requires Flutter 2.8.0/Dart 2.15.0 or newer). #415Store.runIsolated
to runAsync
, drop unused mode
parameter, propagate errors and handle premature isolate exit. #415lib
subfolder on desktop OS (macOS, Linux, Windows). This is where the install.sh
script downloads it by default.dart test
or flutter test
.Query.stream
to collect results in a worker isolate, which should typically be faster. #420Note: the code generated by ObjectBox has breaking changes, make sure to re-generate it after upgrading using
flutter pub run build_runner build
(or dart run build_runner build
for Dart only projects).
Store.runIsolated
to run database operations (asynchronous) in the background (requires Flutter 2.8.0/Dart 2.15.0 or newer). It spawns an isolate, runs the given callback in that isolate with its own Store and returns the result of the callback. This is similar to Flutters compute, but with the callback having access to a Store. #384Store.attach
to attach to a Store opened in a directory. This is an improved replacement for Store.fromReference
to share a Store across isolates. It is no longer required to pass a Store reference and the underlying Store remains open until the last instance is closed. #376output_dir
in pubspec.yaml
. #341