generateTrigger method

String generateTrigger()

Implementation

String generateTrigger() {
  final Map views = local2dart['trigger'] ?? {};
  StringBuffer bufferView = StringBuffer();

  views.forEach((viewName, view) {
    String rawSql = view['raw_sql'] ?? '';
    rawSql = rawSql.replaceAll(RegExp(r'\s+'), ' ').trim();
    if (rawSql.contains("'")) {
      rawSql = rawSql.replaceAll("'", r"\'");
    }

    bufferView.writeln("await db.execute('$rawSql');");
  });

  return bufferView.toString();
}