ClientWorkDb class

The main client implementation of IWorkDb.

This base class implements the WorkDB interface using a pluggable IWorkFileSystem backend without file locking.

Usage

// Create with a specific file system backend
final db = ClientWorkDb(IoWorkDb('./data'));

// Use the database
await db.create(ItemWithId(
  id: 'doc-1',
  collection: 'documents',
  item: {'title': 'Hello'},
));

Multiple Instances

You can create multiple independent database instances with different backends or paths:

final db1 = ClientWorkDb(IoWorkDb('./data1'));
final db2 = ClientWorkDb(IoWorkDb('./data2'));
// db1 and db2 are completely independent

Locking

For thread-safe operations with file locking, use ClientWorkDbLock:

final db = ClientWorkDbLock(IoWorkDb('./data'));
// Operations are protected by file locks
Implemented types
Implementers

Constructors

ClientWorkDb(IWorkFileSystem workDbInternal, {int? maxRecordsPerCollection})
Creates a new ClientWorkDb with the given file system backend.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

clearDatabase() → Future<void>
Clears all data from the database.
override
clearDatabaseSync() → void
Clears all data from the database.
override
create(ItemWithId input) → Future<void>
Creates a new item in the database.
override
createMultiple(List<ItemWithId> inputs) → Future<void>
Creates multiple items in the database.
override
createMultipleSync(List<ItemWithId> inputs) → void
Creates multiple items in the database.
override
createOrUpdate(ItemWithId input) → Future<void>
Creates an item if it doesn't exist, or updates it if it does.
override
createOrUpdateMultiple(List<ItemWithId> inputs) → Future<void>
Creates or updates multiple items in the database.
override
createOrUpdateMultipleSync(List<ItemWithId> inputs) → void
Creates or updates multiple items in the database.
override
createOrUpdateSync(ItemWithId input) → void
Creates an item if it doesn't exist, or updates it if it does.
override
createSync(ItemWithId input) → void
Creates a new item in the database.
override
delete(ItemId input) → Future<void>
Deletes an item from the database.
override
deleteCollection(String collection) → Future<void>
Deletes an entire collection from the database.
override
deleteCollectionSync(String collection) → void
Deletes an entire collection from the database.
override
deleteSync(ItemId input) → void
Deletes an item from the database.
override
getCollections() → Future<List<String>>
Returns a list of all collection names in the database.
override
getCollectionsSync() → List<String>
Returns a list of all collection names in the database.
override
getItemsInCollection(String collection) → Future<List<String>>
Returns a list of all item IDs in a collection.
override
getItemsInCollectionSync(String collection) → List<String>
Returns a list of all item IDs in a collection.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
retrieve(ItemId input) → Future<ItemOutput?>
Retrieves an item from the database.
override
retrieveMultiple(List<ItemId> ids) → Future<List<ItemOutput?>>
Retrieves multiple items from the database.
override
retrieveMultipleSync(List<ItemId> ids) → List<ItemOutput?>
Retrieves multiple items from the database.
override
retrieveSync(ItemId input) → ItemOutput?
Retrieves an item from the database.
override
toString() → String
A string representation of this object.
inherited
update(ItemWithId input) → Future<void>
Updates an existing item in the database.
override
updateSync(ItemWithId input) → void
Updates an existing item in the database.
override

Operators

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