sdbExportDatabaseLines function
- SdbClient client, {
- SdbExportNativeValueEncoder? nativeValueEncoder,
- SdbExportOptions? options,
export a database in a sembast db export format
The header has an sdb_export marker ({'sembast_export': 1, 'version': 1, 'sdb_export': 1}): still a sembast export, it tells the
export can be imported by sdb and idb (sdbImportDatabase,
idbImportDatabase).
A native value (SdbNativeValue) cannot be exported as is: the export
throws an ArgumentError unless nativeValueEncoder (or the one of
options, that overrides it) converts or drops it.
options can give the encoding of the custom types (DateTime,
Uint8List): the legacy @ one by default ({"@Timestamp": ...},
{"@Blob": ...}), or $ ({"$Timestamp": ...}, {"$Blob": ...}, the
header then has "type_prefix": "$").
client is a database or a transaction. A transaction exports its stores
in it, its changes included: writing and exporting can happen in the same
transaction. On the web, an asynchronous nativeValueEncoder can let the
transaction complete before the export ends.
Implementation
Future<List<Object>> sdbExportDatabaseLines(
SdbClient client, {
SdbExportNativeValueEncoder? nativeValueEncoder,
SdbExportOptions? options,
}) async {
if (client is SdbDatabaseImpl) {
// idb based, export the underlying database.
return sdbExportLinesFromIdbExportLines(
await idb.idbExportDatabaseLines(
client.idbDatabase,
nativeValueEncoder: nativeValueEncoder,
options: options,
),
);
}
// Any sdb database and the transactions (read in them).
return sdbExportDatabaseLinesGeneric(
client,
nativeValueEncoder: nativeValueEncoder,
options: options,
);
}