searchByModelAndFields<T extends BaseModel> method
Finds all models in database
that have values that match the passed
model
's values
Only values that are mapped to keys in fields
will be considered.
The default implementation is to call findAllModelsOfTypes and then perform a comparison individiually.
A concrete implementation with a more efficient way of doing this should override this function.
Implementation
FutureOr<Iterable<T>> searchByModelAndFields<T extends BaseModel>(
String database,
T Function() supplier,
T model,
List<String> fields,
) async {
final values = await findAllModelsOfType(database, supplier);
return values.where(
(element) => model.hasSameFields(
model: element,
onlyFields: fields,
),
);
}