generateSeed method
Implementation
String generateSeed() {
final Map seed = local2dart['seed'] ?? {};
StringBuffer buffer = StringBuffer();
seed.forEach((key, value) {
final table = value as Map;
List keys = table['column'];
List values = table['value'];
List<String> sqlValue = [];
for (var element in values) {
final split = element.toString().split(',');
List<String> types = [];
for (var value in split) {
if (RegExp(r'^\d+$').hasMatch(value) ||
RegExp(r'^\d+\.{\d+}$').hasMatch(value)) {
types.add(value);
} else if (RegExp(r'^true$').hasMatch(value)) {
types.add('1');
} else if (RegExp(r'^false$').hasMatch(value)) {
types.add('0');
} else {
types.add('"$value"');
}
}
sqlValue.add('(${types.join(', ')})');
}
buffer.writeln(
"await db.execute('INSERT INTO ${key.toString().snakeCase} (${keys.join(', ')}) VALUES ${sqlValue.join(', ')};');",
);
});
return buffer.toString();
}