getAll method
Returns all the entries in the repository.
If userId
is not null, the results will have the same user id.
If where
is not null, the results will be compliant to the where clause.
Implementation
@override
Future<List<Model>> getAll({String? userId, Where? where, String? orderBy, bool descending = true}) async {
List<Model> data = _getAll();
if (userId != null) {
data = data.where((element) => element.userId == userId).toList();
}
if (where != null) {
data = _filter(data, where);
}
if (orderBy != null) {
final String field = orderBy.toString().split(".").last;
data.sort((a, b) => a.data[field].toString().compareTo(b.data[field].toString()));
}
if (!descending) {
data = data.reversed.toList();
}
return data;
}