exportDatabase function

Future<Map<String, Object?>> exportDatabase(
  1. Database db, {
  2. List<String>? storeNames,
})

Return the data in an exported format that (can be JSONified).

An optional storeNames can specify the list of stores to export. If null All stores are exported.

Implementation

Future<Map<String, Object?>> exportDatabase(Database db,
    {List<String>? storeNames}) async {
  var export = newModel();
  final storesExport = <Map<String, Object?>>[];
  await _exportDatabase(db, exportMeta: (Model map) {
    export.addAll(map);
  }, exportStore: (Model map) {
    storesExport.add(map);
  }, storeNames: storeNames);

  if (storesExport.isNotEmpty) {
    export[_stores] = storesExport;
  }
  return export;
}