update method

Future<DbResult> update(
  1. Map<String, Object?> data
)

Implementation

Future<DbResult> update(Map<String, Object?> data) async {
  _ensureNotConsumed();
  if (_whereClauses.isEmpty) {
    throw StateError('update() without where() would affect all rows. Use AppAmbitDb.execute() for intentional full-table updates.');
  }
  final cols = data.keys.toList();
  final setClauses = cols.map((c) => '${_quoteId(c)} = ?').join(', ');
  final sql = 'UPDATE ${_quoteId(_table)} SET $setClauses WHERE ${_joinConditions()}';
  final params = [...cols.map((c) => data[c]), ..._whereParams];
  final raw = await AppAmbitSdkFlutterPlatform.instance.dbExecute(sql, params);
  return DbResult.fromMap(raw);
}