firstWhereOrNull method
Future<TEntity?>
firstWhereOrNull(
{ - Iterable<ColumnDefinition<IEntity, dynamic>>? columns(
- TMeta t
)?,
- List<OrmOrder>? orderBy(
- TMeta t
)?,
- required Filter where(
- TMeta t
),
- int? offset,
- bool? useIsolate,
- Map<String, dynamic>? isolateArgs,
- void onIsolatePreMap(
- Map<String, dynamic>? isolateArgs
)?,
})
Implementation
@override
Future<TEntity?> firstWhereOrNull({
Iterable<ColumnDefinition>? Function(TMeta t)? columns,
List<OrmOrder>? Function(TMeta t)? orderBy,
required Filter Function(TMeta t) where,
int? offset,
final bool? useIsolate,
Map<String, dynamic>? isolateArgs,
void Function(Map<String, dynamic>? isolateArgs)? onIsolatePreMap,
}) async {
Map<String, dynamic> records = await getItems() ?? {};
final filters = where(t).filters;
final res = records.entries.firstWhereOrNull(
(element) {
return _where(element, filters);
},
);
if (res != null) {
return mType.load(res.value as Map<String, dynamic>) as TEntity;
}
return null;
}