List Databases
Retrieve all databases in your account with optional pagination, sorting, filtering, and connector scoping using the client.databases.findAll() method. This operation allows you to discover and manage your database collection efficiently.
Method Signature
client.databases.findAll(options?: DatabaseQueryOptions): Promise<BolticListResponse<DatabaseRecord> | BolticErrorResponse>
Parameters
DatabaseQueryOptions
| Parameter | Type | Required | Description |
|---|---|---|---|
connector_id | string | ❌ | Resource identifier (defaults to "boltic"). For custom resources, use btb-* connector IDs. Refer to connectors list |
page | PaginationParams | ❌ | Pagination parameters (page_no, page_size) |
sort | SortParams[] | ❌ | Array of sort criteria |
filters | FilterParams[] | ❌ | Array of filter criteria (status filter is always overridden to ACTIVE) |
fields | string[] | ❌ | Array of field names to return |
Return Value
BolticListResponse<DatabaseRecord>
interface BolticListResponse<DatabaseRecord> {
data: DatabaseRecord[];
pagination?: {
total_count: number;
total_pages: number;
current_page: number;
per_page: number;
type: string;
};
}
DatabaseRecord
Each item in the data array is a DatabaseRecord with the following structure:
interface DatabaseRecord {
id: string; // Unique database identifier (UUID)
account_id: string; // Account identifier
db_name: string; // Display name of the database
db_internal_name: string; // Internal name (slug) used for switching
db_username: string; // Database username
resource_id: string; // Resource identifier
status: "ACTIVE"; // Database status (always "ACTIVE" in results)
is_default: boolean; // Whether this is the default database
rank: number; // Database ranking/order
created_by: string; // Creator identifier
updated_by: string; // Last updater identifier
created_at: string; // Creation timestamp (ISO 8601)
updated_at: string; // Last update timestamp (ISO 8601)
}
Examples
Basic List (Default Resource)
import { createClient } from "@boltic/sdk";
const client = createClient("your-api-key");
const { data: databases, error } = await client.databases.findAll();
if (error) {
console.error("Failed to list databases:", error.message);
} else {
console.log(`Found ${databases.length} active databases`);
databases.forEach((db) => {
console.log(`- ${db.db_name} (${db.db_internal_name})`);
});
}
List with Pagination and Sorting
const { data: databases, error } = await client.databases.findAll({
page: { page_no: 1, page_size: 5 },
sort: [{ field: "db_name", direction: "asc" }],
});
if (!error) {
console.log(`Page 1: ${databases.length} databases`);
}
List Databases in Custom Resource
// List databases in a custom resource (connector ID starting with 'btb-')
const { data: customDbs, error } = await client.databases.findAll({
connector_id: "btb-abc123xyz", // Your custom connector ID
page: { page_no: 1, page_size: 10 },
});
if (!error) {
console.log(`Found ${customDbs.length} active databases in custom resource`);
}
List with Filters
// Filter databases by name pattern
const { data: databases, error } = await client.databases.findAll({
filters: [{ field: "db_name", operator: "ILIKE", values: ["%demo%"] }],
});
if (!error) {
console.log(`Found ${databases.length} databases matching pattern`);
}