sdb library
Simple DB.
Opinionated strong type API. Design around indexed db API which is a
basic database API easy to implement with good web support and robust
desktop implementation using idb_sqflite
In memory available (mainly for testing) and io implementation using sembast
Classes
- Database
- provides a connection to a database; you can use an Database object to open a transaction on your database then create, manipulate, and delete objects (data) in that database. The interface provides the only way to get and manage versions of the database.
- Event
- Event abstraction for onBlockedFunction
- IdbCursor
- represents a cursor for traversing or iterating over multiple records in a database.
- IdbCursorWithValue
- represents a cursor for traversing or iterating over multiple records in a database. It is the same as the Cursor, except that it includes the value property.
- IdbFactory
- Out factory for opening a database instead of using window.indexedDB
- Index
- provides asynchronous access to an index in a database. An index is a kind of object store for looking up records in another object store, called the referenced object store. You use this interface to retrieve data.
- KeyRange
- represents a continuous interval over some data type that is used for keys.
- ObjectStore
- represents an object store in a database. Records within an object store are sorted according to their keys. This sorting enables fast insertion, look-up, and ordered retrieval.
- OpenDBRequest
- provides access to the results of requests to open or delete databases
- Request
- provides access to results of asynchronous requests to databases and database objects using event handler attributes. Each reading and writing operation on a database is done using a request.
-
SdbBoundaries<
T extends Object> - Lower and upper boundaries.
-
SdbBoundary<
T extends Object> - Simple boundary definition. include default to true for lower boundary and false for upper boundary.
- SdbClient
- Database client (db or transaction).
- SdbDatabase
- SimpleDb definition.
- SdbFactory
- Sdb Factory
-
SdbIndex1Ref<
K extends SdbKey, V extends SdbValue, I extends SdbIndexKey> - Index on 1 field
-
SdbIndex2Ref<
K extends SdbKey, V extends SdbValue, I1 extends SdbIndexKey, I2 extends SdbIndexKey> - Index on 2 fields
-
SdbIndex3Ref<
K extends SdbKey, V extends SdbValue, I1 extends SdbIndexKey, I2 extends SdbIndexKey, I3 extends SdbIndexKey> - Index on 3 fields
-
SdbIndex4Ref<
K extends SdbKey, V extends SdbValue, I1 extends SdbIndexKey, I2 extends SdbIndexKey, I3 extends SdbIndexKey, I4 extends SdbIndexKey> - Index on 4 fields
-
SdbIndexRecordKey<
K extends SdbKey, V extends SdbValue, I extends SdbIndexKey> - Index record key.
-
SdbIndexRecordRef<
K extends SdbKey, V extends SdbValue, I extends SdbIndexKey> - Index record reference.
-
SdbIndexRecordSnapshot<
K extends SdbKey, V extends SdbValue, I extends SdbIndexKey> - Index record snapshot.
-
SdbIndexRef<
K extends SdbKey, V extends SdbValue, I extends SdbIndexKey> - Index reference.
-
SdbLowerBoundary<
T extends Object> - Lower boundary. (included by default).
- SdbMultiStoreTransaction
- Multi-store transaction.
- SdbOpenDatabase
- Database during open.
-
SdbOpenIndexRef<
K extends SdbKey, V extends SdbValue, I extends SdbIndexKey> - Index during open.
-
SdbOpenStoreRef<
K extends SdbKey, V extends SdbValue> - Store during open.
-
SdbRecordKey<
K extends SdbKey, V extends SdbValue> - Record snapshot.
-
SdbRecordSnapshot<
K extends SdbKey, V extends SdbValue> - Record snapshot.
-
SdbSingleStoreTransaction<
K extends SdbKey, V extends SdbValue> - Single store transaction.
-
SdbStoreRef<
K extends SdbKey, V extends SdbValue> - A simple db store definition.
- SdbTransaction
- SimpleDb transaction.
-
SdbTransactionStoreRef<
K extends SdbKey, V extends SdbValue> - Transaction store reference.
-
SdbUpperBoundary<
T extends Object> - Upper boundary. (excluded by default).
- SdbVersionChangeEvent
- Event passed to SdbOnVersionChangeCallback.
- Transaction
- static, asynchronous transaction on a database using event handler attributes. All reading and writing of data is done within transactions. You actually use Database to start transactions and Transaction to set the mode of the transaction (e.g. is it readonly or readwrite), and access an ObjectStore to make a request. You can also use it to abort transactions.
- VersionChangeEvent
- indicates that the version of the database has changed, as the result of an onupgradeneeded event handler function.
Enums
- SdbTransactionMode
- Transaction mode.
Extensions
- IdbFactoryExt on IdbFactory
- Helper extension
- IdbFactoryLoggerDebugExt on IdbFactory
- Debug extension for Logger.
- SdbClientExtension on SdbClient
- Database client (db or transaction).
- SdbDatabaseExtension on SdbDatabase
- SimpleDb methods.
- SdbDatabaseIdbExt on SdbDatabase
- Helper idb extension.
- SdbFactoryExtension on SdbFactory
- Sdb Factory extension.
- SdbFilterRecordSnapshotExt on SdbFilterRecordSnapshot
- Extension to allow getting the primary key for index requests
-
SdbIndex1RefExtension
on SdbIndex1Ref<
K, V, I> - Extension on index on 1 field.
-
SdbIndex2RefExtension
on SdbIndex2Ref<
K, V, I1, I2> - Extension on index on 2 fields.
-
SdbIndex3RefExtension
on SdbIndex3Ref<
K, V, I1, I2, I3> - Extension on index on 3 fields.
-
SdbIndex4RefExtension
on SdbIndex4Ref<
K, V, I1, I2, I3, I4> - Extension on index on 4 fields.
-
SdbIndexRecordKeyListExt
on List<
SdbIndexRecordKey< K, V, I> > - Common extension
-
SdbIndexRecordRefExtension
on SdbIndexRecordRef<
K, V, I> - Index record reference extension.
-
SdbIndexRecordSnapshotListExt
on List<
SdbIndexRecordSnapshot< K, V, I> > - Common extension
-
SdbIndexRefExtension
on SdbIndexRef<
K, V, I> - Index methods.
- SdbMultiStoreTransactionExtension on SdbMultiStoreTransaction
- Transaction store actions.
- SdbOpenDatabaseExtension on SdbOpenDatabase
- Database action during open.
-
SdbOpenStoreRefExtension
on SdbOpenStoreRef<
K, V> - Store action during open.
-
SdbRecordKeyListExt
on List<
SdbRecordKey< K, V> > - Common extension
-
SdbRecordRefExtension
on SdbRecordRef<
K, V> - Store methods.
-
SdbRecordSnapshotListExt
on List<
SdbRecordSnapshot< K, V> > - Common extension
-
SdbSingleStoreTransactionExtension
on SdbSingleStoreTransaction<
K, V> - Single store transaction extension.
-
SdbStoreRefDbExtension
on SdbStoreRef<
K, V> - Store reference implementation.
-
SdbStoreRefExtension
on SdbStoreRef<
K, V> - Store methods.
- SdbTransactionExtension on SdbTransaction
- SimpleDb transaction extension.
-
SdbTransactionStoreRefExtension
on SdbTransactionStoreRef<
K, V> - Transaction store actions.
Constants
- idbDirectionNext → const String
- Default forward mode for cursor.
- idbDirectionPrev → const String
- Backward mode for cursor.
- idbFactoryNameBrowser → const String
- Pseudo - best browser shim (persistent of it not available memory).
- idbFactoryNameLogger → const String
- Factory name logger (wrapping another factory).
- idbFactoryNameMemory → const String
- Factory name that could be used to use Sembast Memory implementation.
- idbFactoryNameNative → const String
- Factory name using native indexeddb implementation.
- idbFactoryNamePersistent → const String
- Pseudo - best persistent shim (indexeddb).
- idbFactoryNameSembastIo → const String
- Factory name using Sembast implementation
- idbFactoryNameSembastMemory → const String
- Factory name using Sembast memory implementation
- idbModeReadOnly → const String
- Read-only mode for transaction.
- idbModeReadWrite → const String
- Read-write mode for transaction.
- kIdbDartIsWeb → const bool
- Borrowed from flutter (isRunningAsJavascript is false in wasm)
- kSdbDartIsWeb → const bool
- Web constant helper (needed for non-flutter app)
Properties
- idbFactoryMemory → IdbFactory
-
The in-memory factory
no setter
- idbFactoryMemoryFs → IdbFactory
-
Special factory in memory but supporting writing on a virtual file system (in memory too)
no setter
- idbFactoryNative → IdbFactory
-
The native factory
no setter
- idbFactoryWeb → IdbFactory
-
The web factory
no setter
- idbFactoryWebSupported → bool
-
no setter
- idbFactoryWebWorker → IdbFactory
-
The web worker
no setter
- idbFactoryWebWorkerSupported → bool
-
no setter
- sdbFactoryIo → SdbFactory
-
Sembast io factory.
final
- sdbFactoryMemory → SdbFactory
-
Memory factory.
final
- sdbFactoryWeb → SdbFactory
-
Native (browser) factory.
final
- sdbFactoryWebWorker → SdbFactory
-
Native (web worker) factory.
final
Functions
-
newIdbFactoryMemory(
) → IdbFactory - An empty in-memory factory, good for unit test.
-
newSdbFactoryMemory(
) → SdbFactory - New memory factory.
-
sdbFactoryFromIdb(
IdbFactory idbFactory) → SdbFactory - Factory from idb factory.
Typedefs
- Cursor = IdbCursor
- Compat, prefer IdbCursor
- CursorWithValue = IdbCursorWithValue
- Compat, prefer IdbCursorWithValue
- IdbCursorWithValueMatcherFunction = bool Function(IdbCursorWithValue cursor)
- Matching function for a cursor with value.
- OnBlockedFunction = void Function(Event event)
- OnBlocked function.
-
OnUpgradeNeededFunction
= FutureOr<
void> Function(VersionChangeEvent event) - OnUpgrade function.
- SdbFilter = Filter
- Sdb filter
-
SdbFilterRecordSnapshot
= RecordSnapshot<
Object?, Object?> - Sdb custom filter matcher
- SdbIndexKey = Object
- Value type. Index type.
- SdbKey = Object
- Key type
-
SdbModel
= Map<
String, Object?> - Model class.
-
SdbOnVersionChangeCallback
= FutureOr<
void> Function(SdbVersionChangeEvent event) -
Callback for
SdbOpenDatabase.onVersionChange
. -
SdbRecordRef<
K extends SdbKey, V extends SdbValue> = SdbRecordKey< K, V> - Record reference.
- SdbValue = Object
- Value type
Exceptions / Errors
- DatabaseError
- Generic database error.
- DatabaseException
- Generic database exception.
- DatabaseIndexNotFoundError
- Index not found.
- DatabaseInvalidKeyError
- invalid key error.
- DatabaseNoKeyError
- no key error.
- DatabaseReadOnlyError
- Read only error.
- DatabaseStoreNotFoundError
- Store not found error.
- DatabaseTransactionStoreNotFoundError
- Store not found.