updateMap method

int? updateMap(
  1. TableName table,
  2. Map<String, dynamic> values,
  3. String where
)

Update a new record using a map and a where condition.

This returns the number of rows affected.

Implementation

int? updateMap(TableName table, Map<String, dynamic> values, String where) {
  List<dynamic> args = [];
  var keysVal;
  values.forEach((key, value) {
    if (keysVal == null) {
      keysVal = "$key=?";
    } else {
      keysVal += ",$key=?";
    }
    args.add(value);
  });

  var sql = "update ${table.fixedName} set $keysVal where $where;";
  return execute(sql, arguments: args);
}