insertOrReplaceWith method

  1. @override
Statement insertOrReplaceWith(
  1. QualifiedTablename table,
  2. List<String> columns,
  3. List<Object?> values,
  4. List<String> conflictCols,
  5. List<String> updateCols,
  6. List<Object?> updateVals,
)
override

Insert a row into a table. If it already exists we update the provided columns updateCols with the provided values updateVals

Implementation

@override
Statement insertOrReplaceWith(
  QualifiedTablename table,
  List<String> columns,
  List<Object?> values,
  List<String> conflictCols,
  List<String> updateCols,
  List<Object?> updateVals,
) {
  final insertOrReplaceRes = insertOrReplace(
    table,
    columns,
    values,
    conflictCols,
    updateCols,
  );
  return Statement(
    '${insertOrReplaceRes.sql} ON CONFLICT DO UPDATE SET ${updateCols.map((col) => '$col = ?').join(', ')}',
    [...insertOrReplaceRes.args!, ...updateVals],
  );
}