upsert method

Future<List<GoogleAccount>> upsert(
  1. DatabaseSession session,
  2. List<GoogleAccount> rows, {
  3. required ColumnSelections<GoogleAccountTable> conflictColumns,
  4. ColumnSelections<GoogleAccountTable>? updateColumns,
  5. WhereExpressionBuilder<GoogleAccountTable>? updateWhere,
  6. Transaction? transaction,
  7. bool noReturn = false,
})

Upserts all GoogleAccounts in the list and returns the resulting rows.

If a row conflicts on the given conflictColumns, the existing row is updated with the new values. 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 to rows matching the given expression. Conflicting rows that don't match are skipped and not returned, so the resulting list may be shorter than rows.

The returned GoogleAccounts will have their id fields set.

This is an atomic operation, meaning that if one of the rows fails, none of the rows will be affected.

If noReturn is set to true, the resulting rows are not read back from the database and an empty list is returned. This avoids the overhead of transferring and deserializing the rows when the result is not needed.

Implementation

Future<List<GoogleAccount>> upsert(
  _i1.DatabaseSession session,
  List<GoogleAccount> rows, {
  required _i1.ColumnSelections<GoogleAccountTable> conflictColumns,
  _i1.ColumnSelections<GoogleAccountTable>? updateColumns,
  _i1.WhereExpressionBuilder<GoogleAccountTable>? updateWhere,
  _i1.Transaction? transaction,
  bool noReturn = false,
}) async {
  return session.db.upsert<GoogleAccount>(
    rows,
    conflictColumns: conflictColumns(GoogleAccount.t),
    updateColumns: updateColumns?.call(GoogleAccount.t),
    updateWhere: updateWhere?.call(GoogleAccount.t),
    transaction: transaction,
    noReturn: noReturn,
  );
}