fillIfAbsent method

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

Mass assigns only values that are currently absent.

Supports maps, tracked models, DTOs, and partial entities.

Implementation

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