firstWhereOrNull method

  1. @override
Future<TEntity?> firstWhereOrNull({
  1. Iterable<ColumnDefinition<IEntity, dynamic>>? columns(
    1. TMeta t
    )?,
  2. List<OrmOrder>? orderBy(
    1. TMeta t
    )?,
  3. required Filter where(
    1. TMeta t
    ),
  4. int? offset,
  5. bool? useIsolate,
  6. Map<String, dynamic>? isolateArgs,
  7. void onIsolatePreMap(
    1. 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;
}