insertOrIgnore method

  1. @override
Statement insertOrIgnore(
  1. QualifiedTablename table,
  2. List<String> columns,
  3. List<Object?> values
)
override

Insert a row into a table, ignoring it if it already exists.

Implementation

@override
Statement insertOrIgnore(
  QualifiedTablename table,
  List<String> columns,
  List<Object?> values,
) {
  return Statement(
    '''
      INSERT INTO $table (${columns.map(quote).join(', ')})
        VALUES (${columns.mapIndexed((i, _) => '\$${i + 1}').join(', ')})
        ON CONFLICT DO NOTHING;
    ''',
    values,
  );
}