update-record.ais
execute(input)
database = service "database_tasks"
task = database.first({
from: "Task (id, status)",
where: { id: input.taskId, deleted: false },
locking: { type: "forUpdate" }
})
if task == null
fail NotFound "Active task not found"
end
if task.status != "pending"
fail Conflict "Only a pending task can be reviewed"
end
// Review this record within the current transaction.
task.status = "reviewed"
task.save()
return { taskId: task.id, status: task.status }
end
All examples