getJobById method

Future<BackgroundJob?> getJobById(
  1. int id
)

Fetches a single job by its ID.

Returns the BackgroundJob if found, otherwise null.

Implementation

Future<BackgroundJob?> getJobById(int id) async {
  final List<Map<String, Object?>> result = await db.getAll(
    "SELECT * FROM background_service_jobs WHERE id = ? LIMIT 1",
    [id],
  );
  if (result.isNotEmpty) {
    return BackgroundJob.fromMap(result.first);
  }
  return null;
}