fillIfAbsent method

Model<OrmMigrationRecord> fillIfAbsent(
  1. Map<String, Object?> attributes, {
  2. bool strict = false,
  3. ValueCodecRegistry? registry,
})
inherited

Mass assigns only values that are currently absent.

Implementation

Model<TModel> fillIfAbsent(
  Map<String, Object?> attributes, {
  bool strict = false,
  ValueCodecRegistry? registry,
}) {
  final pending = <String, Object?>{};
  final existing = _asAttributes.attributes;
  for (final entry in attributes.entries) {
    if (!existing.containsKey(entry.key) || existing[entry.key] == null) {
      pending[entry.key] = entry.value;
    }
  }
  _asAttributes.fillAttributes(
    pending,
    strict: strict,
    registry: _effectiveCodecRegistry(registry),
  );
  return _self();
}