updateJobStatusByJobKey method

Future<int> updateJobStatusByJobKey(
  1. String jobKey,
  2. BackgroundJobStatus newStatus, {
  3. required String message,
})

Updates the status and message for all jobs with a specific jobKey.

  • jobKey: The key of the jobs to update.
  • newStatus: The new BackgroundJobStatus.
  • message: The new message for the jobs. Returns the number of rows affected.

Implementation

Future<int> updateJobStatusByJobKey(
  String jobKey,
  BackgroundJobStatus newStatus, {
  required String message,
}) async {
  final ResultSet result = await db.execute(
    "UPDATE background_service_jobs SET status = ?, message = ? WHERE job_key = ?",
    [newStatus.name.toUpperCase(), message, jobKey],
  );
  return result.length;
}