upsertRow method

Future<CrdtDataRow?> upsertRow(
  1. DatabaseSession session,
  2. CrdtDataRow row, {
  3. required ColumnSelections<CrdtDataRowTable> conflictColumns,
  4. ColumnSelections<CrdtDataRowTable>? updateColumns,
  5. WhereExpressionBuilder<CrdtDataRowTable>? updateWhere,
  6. Transaction? transaction,
})

Upserts a single CrdtDataRow and returns the resulting row.

If the row conflicts on the given conflictColumns, the existing row is updated. Otherwise, a new row is inserted.

If updateColumns is provided, only those columns will be updated on conflict. If null, all non-conflict, non-id columns are updated.

If updateWhere is provided, the update only applies when the existing row matches the expression. Returns null if no row was affected — for example when updateWhere does not match the conflicting row.

The returned CrdtDataRow will have its id field set.

Implementation

Future<CrdtDataRow?> upsertRow(
  _isd.DatabaseSession session,
  CrdtDataRow row, {
  required _isd.ColumnSelections<CrdtDataRowTable> conflictColumns,
  _isd.ColumnSelections<CrdtDataRowTable>? updateColumns,
  _isd.WhereExpressionBuilder<CrdtDataRowTable>? updateWhere,
  _isd.Transaction? transaction,
}) async {
  return session.db.upsertRow<CrdtDataRow>(
    row,
    conflictColumns: conflictColumns(CrdtDataRow.t),
    updateColumns: updateColumns?.call(CrdtDataRow.t),
    updateWhere: updateWhere?.call(CrdtDataRow.t),
    transaction: transaction,
  );
}