hasSameFields<T extends BaseModel> method

bool hasSameFields<T extends BaseModel>({
  1. required T model,
  2. Iterable<String>? onlyFields,
  3. Iterable<String>? exceptFields,
})

Returns whether the given model has the same given fields as this model.

onlyFields and exceptFields can be used to limit the fields that are compared. The two are mutually exclusive and an error will be thrown if both are specified.

Implementation

bool hasSameFields<T extends BaseModel>({
  required T model,
  Iterable<String>? onlyFields,
  Iterable<String>? exceptFields,
}) {
  return fieldsToEvaluate(onlyFields, exceptFields)
      .map(
        (e) => _equality(getField(e), model.getField(e)),
      )
      .reduce((value, element) => value && element);
}