sdbImportDatabase function
Copy a database export (lines or map sembast export) to another
return the opened database
Implementation
Future<Database> sdbImportDatabase(
Object data, IdbFactory dstFactory, String dstDbName) async {
// if it is a sembast factory use it!
// if (false) {
if (dstFactory is IdbFactorySembast) {
final sdbDb = await sembast.importDatabaseAny(
data, dstFactory.sdbFactory, dstFactory.getDbPath(dstDbName));
return dstFactory.openFromSdbDatabase(sdbDb);
} else {
// import to a memory one
final sdbDb = await sembast.importDatabaseAny(
data, sembast.databaseFactoryMemory, _tempExportPath);
final tmpDb = await (idbFactoryMemory as IdbFactorySembast)
.openFromSdbDatabase(sdbDb);
final db = await copyDatabase(tmpDb, dstFactory, dstDbName);
tmpDb.close();
return db;
}
}