updateJobStatus method
Updates the status of a specific job.
id
: The ID of the job to update.newStatus
: The new BackgroundJobStatus.lastError
: Optional error message if the status is BackgroundJobStatus.failed. Returns the number of rows affected (should be 1 if successful).
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;
}