mysql1_dart
mysql1_dart copied to clipboard
add a method that returns the data as a map list just like the "postgres" package
add a method that returns the data as a map list just like the "postgres" package, I thought of an implementation like this, maybe an extension of the Results class
extension Mysql1ToMapsExtension on Results {
Future<List<Map<String, dynamic>>> asMaps() async {
var listMap = <Map<String, dynamic>>[];
var fields = this.fields;
await this.forEach((ResultRow row) {
var map = <String, dynamic>{};
for (var i = 0; i < row.length; i++) {
map.addAll({fields[i].name: row[i]});
}
listMap.add(map);
});
return listMap;
}
}