updateJobStatus method

Future<int> updateJobStatus(
  1. int id,
  2. BackgroundJobStatus newStatus, {
  3. String? lastError,
})

Updates the status of a specific job.

Implementation

Future<int> updateJobStatus(
  int id,
  BackgroundJobStatus newStatus, {
  String? lastError,
}) async {
  final ResultSet result = await db.execute(
    "UPDATE background_service_jobs SET status = ?, last_error = ?, last_attempt_at = STRFTIME('%Y-%m-%dT%H:%M:%fZ', 'NOW') WHERE id = ?",
    [newStatus.name.toUpperCase(), lastError, id],
  );
  return result.length;
}