Skip to main content

List Database Jobs

Retrieve all database jobs (primarily deletion jobs) with optional filtering, sorting, and pagination using the client.databases.listJobs() method. This operation allows you to monitor and track the status of asynchronous database operations.

Method Signature​

client.databases.listJobs(options?: DatabaseJobQueryOptions): Promise<BolticListResponse<DatabaseJobRecord> | BolticErrorResponse>

Parameters​

DatabaseJobQueryOptions​

ParameterTypeRequiredDescription
deleted_by_meboolean❌Filter to show only jobs created by current user
pagePaginationParams❌Pagination parameters (page_no, page_size)
sortSortParams[]❌Array of sort criteria
filtersFilterParams[]❌Array of filter criteria
fieldsstring[]❌Array of field names to return

Return Value​

BolticListResponse<DatabaseJobRecord>​

interface BolticListResponse<DatabaseJobRecord> {
data: DatabaseJobRecord[];
pagination?: {
total_count: number;
total_pages: number;
current_page: number;
per_page: number;
type: string;
};
}

DatabaseJobRecord​

Each item in the data array is a DatabaseJobRecord with the following structure:

interface DatabaseJobRecord {
id: string; // Unique job identifier (UUID)
account_id: string; // Account identifier
resource_id: string; // Resource identifier
type: string; // Job type
action: "DELETE"; // Job action type
db_id: string; // Database ID being processed
db_internal_name: string; // Database internal name (slug)
db_username: string; // Database username
job_status: "pending" | "in_progress" | "success" | "failed"; // Current job status
total_dbs: number; // Total databases in the job
successful_dbs: number; // Number of successfully processed databases
failed_dbs: number; // Number of failed databases
error: string | null; // Error message if job failed
is_read: boolean; // Whether the job has been read
created_by: string; // Creator identifier
created_at: string; // Creation timestamp (ISO 8601)
updated_at: string; // Last update timestamp (ISO 8601)
}

Examples​

Basic List (All Jobs)​

import { createClient } from "@boltic/sdk";

const client = createClient("your-api-key");

const { data: jobs, error } = await client.databases.listJobs();

if (error) {
console.error("Failed to list jobs:", error.message);
} else {
console.log(`Found ${jobs.length} database jobs`);
jobs.forEach((job) => {
console.log(`- Job ${job.id}: ${job.action} - ${job.job_status}`);
});
}

List Jobs with Pagination and Sorting​

const { data: jobs, error } = await client.databases.listJobs({
page: { page_no: 1, page_size: 10 },
sort: [{ field: "created_at", direction: "desc" }],
});

if (!error) {
console.log(`Page 1: ${jobs.length} jobs`);
jobs.forEach((job) => {
console.log(`Job ${job.id} - Status: ${job.job_status}, Created: ${job.created_at}`);
});
}

List Jobs Created by Current User​

// List only jobs created by the current user
const { data: myJobs, error } = await client.databases.listJobs({
deleted_by_me: true,
page: { page_no: 1, page_size: 20 },
sort: [{ field: "created_at", direction: "desc" }],
});

if (!error) {
console.log(`Found ${myJobs.length} jobs created by you`);
}

List Jobs with Filters​

// List jobs with specific status
const { data: pendingJobs, error } = await client.databases.listJobs({
filters: [{ field: "job_status", operator: "=", values: ["pending"] }],
});

if (!error) {
console.log(`Found ${pendingJobs.length} pending jobs`);
}