Instantly share code, notes, and snippets.

Embed
What would you like to do?
void insert(List<DatabaseModel> models) async {
var db = await database;
var batch = db.batch();
for (var model in models) {
DatabaseTable table = _tables[model.runtimeType];
if (table == null) {
return;
}
batch.insert(table.name, model.toMap());
}
await batch.commit();
}
Future<List<Map>> fetchAllEntriesOf(Type type) async {
DatabaseTable table = _tables[type];
if (table == null) {
return [];
}
var db = await database;
var maps = await db.query(table.name, columns: table.columns);
return maps;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment