getById method

  1. @override
Future<Either<String, ComponentTemplate>> getById(
  1. String id
)
override

Get single component by ID

Implementation

@override
Future<Either<String, ComponentTemplate>> getById(String id) async {
  try {
    final model = await isar.componentModels
        .filter()
        .componentIdEqualTo(id)
        .findFirst();
    if (model == null) {
      return const Left('Component not found');
    }
    return Right(model.toDomain());
  } catch (e) {
    return Left('Failed to fetch component: $e');
  }
}