watchAllJobs method

Stream<List<BackgroundJob>> watchAllJobs()

Watches all jobs in the database, emitting a new list whenever the background_service_jobs table changes.

Jobs are sorted by creation date, with the newest jobs first.

Implementation

Stream<List<BackgroundJob>> watchAllJobs() {
  final stream = db.watch(
    "SELECT * FROM background_service_jobs ORDER BY created_at DESC",
  );
  return stream.map(
    (results) => results.map((map) => BackgroundJob.fromMap(map)).toList(),
  );
}