Store class

Represents an ObjectBox database and works together with Box to allow getting and putting.

Implemented types
Available extensions

Constructors

Store(ModelDefinition modelDefinition, {String? directory, int? maxDBSizeInKB, int? maxDataSizeInKB, int? fileMode, int? maxReaders, int? debugFlags, bool queriesCaseSensitiveDefault = true, String? macosApplicationGroup})
Creates a BoxStore using the model definition from your objectbox.g.dart file in the given directory path (or if null the defaultDirectoryPath).
Store.attach(ModelDefinition modelDefinition, String? directoryPath, {bool queriesCaseSensitiveDefault = true})
Attach to a store opened in the directoryPath (or if null the defaultDirectoryPath).
Store.fromReference(ModelDefinition modelDefinition, ByteData _reference, {bool queriesCaseSensitiveDefault = true})
Create a Dart store instance from an existing native store reference.

Properties

directoryPath → String
Path to the database directory.
no setter
entityChanges → Stream<List<Type>>

Available on Store, provided by the ObservableStore extension

Returns a broadcast stream to data changes on all Entity types.
no setter
hashCode → int
The hash code for this object.
no setterinherited
reference → ByteData
Returns a store reference you can use to create a new store instance with a single underlying native store. See Store.fromReference for more details.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

awaitQueueCompletion() → bool
Await for all (including future) submissions using Box.putQueued to be completed (the queue becomes idle for a moment).
awaitQueueSubmitted() → bool
Await for previously submitted operations using Box.putQueued to be completed (the queue does not have to become idle).
box<T>() → Box<T>
Returns a cached Box instance.
close() → void
Closes this store.
isClosed() → bool
Returns if this store is already closed and can no longer be used.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
runAsync<P, R>(RunAsyncCallback<P, R> callback, P param) → Future<R>
Spawns an isolate, runs callback in that isolate passing it param with its own Store and returns the result of callback.
runInTransaction<R>(TxMode mode, R fn()) → R
Executes a given function inside a transaction. Returns fn's result. Aborts a transaction and rethrows on exception if fn is asynchronous.
runInTransactionAsync<R, P>(TxMode mode, TxAsyncCallback<R, P> callback, P param) → Future<R>
Like runAsync, but executes callback within a read or write transaction depending on mode.
syncClient() → SyncClient?
Return an existing SyncClient associated with the store or null if not available. Use Sync.client() to create one first.
toString() → String
A string representation of this object.
inherited
watch<EntityT>() → Stream<void>

Available on Store, provided by the ObservableStore extension

Create a stream to data changes on EntityT (stored Entity class).

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

debugLogs ↔ bool
Enables a couple of debug logs. This meant for tests only; do not enable for releases!
getter/setter pair

Static Methods

databaseVersion() → String
Returns the version and features of the platform-specific ObjectBox database library.
dbFileSize(String? directoryPath) → int
Returns the file size in bytes of the main database file for the given directoryPath, or 0 if the file does not exist or some error occurred.
isOpen(String? directoryPath) → bool
Returns if an open store (i.e. opened before and not yet closed) was found for the given directoryPath.
removeDbFiles(String? directoryPath) → void
Danger zone! This will delete all files in the given directory!

Constants

defaultDirectoryPath → const String
Path of the default directory, currently 'objectbox'.
inMemoryPrefix → const String
Pass this together with a String identifier as the directory path to use a file-less in-memory database.