List Columns
Retrieve all columns in a table with powerful filtering, sorting, and pagination capabilities.
findAll()
Retrieve columns with optional query parameters for filtering, sorting, and pagination.
client.columns.findAll(tableName: string, options?: ColumnQueryOptions): Promise<BolticListResponse<ColumnDetails> | BolticErrorResponse>
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
tableName | string | ✅ | Name of the target table |
options | ColumnQueryOptions | ❌ | Query options for filtering, sorting, pagination |
ColumnQueryOptions
Property | Type | Description |
---|---|---|
where | Record<string, any> | Filter conditions using operators |
fields | string[] | Specific fields to include in response |
sort | SortOption[] | Sort criteria with field and direction |
limit | number | Maximum number of results to return |
offset | number | Number of results to skip |
page | { page_no: number, page_size: number } | Page-based pagination |
Basic Usage
Get All Columns
const { data: columns, error } = await client.columns.findAll("products");
if (!error) {
console.log(`Found ${columns.length} columns:`);
columns.forEach((column) => {
console.log(`- ${column.name} (${column.type})`);
});
}
Response Format
{
data: [
{
id: "col_123456",
name: "title",
type: "text",
description: "Product title",
is_nullable: false,
is_indexed: true,
is_unique: false,
is_visible: true,
default_value: null,
created_at: "2024-01-01T00:00:00Z",
updated_at: "2024-01-01T00:00:00Z"
},
{
id: "col_789012",
name: "price",
type: "currency",
currency_format: "USD",
decimals: "0.00",
description: "Product price",
is_nullable: false,
is_indexed: true,
// ... more properties
}
// ... more columns
],
pagination: {
current_page: 1,
total_pages: 2,
total_count: 15,
page_size: 10
}
}
Filtering
Use the where
parameter with filter operators to find specific columns.
Basic Filtering
// Get all text columns
const { data: textColumns } = await client.columns.findAll("products", {
where: { type: "text" },
});
// Get nullable columns
const { data: nullableColumns } = await client.columns.findAll("products", {
where: { is_nullable: true },
});
// Get indexed columns
const { data: indexedColumns } = await client.columns.findAll("products", {
where: { is_indexed: true },
});
Filter Operators
Operator | Description | Example |
---|---|---|
$eq | Equal to | { type: { $eq: 'text' } } |
$ne | Not equal to | { type: { $ne: 'text' } } |
$in | In array | { type: { $in: ['text', 'email'] } } |
$nin | Not in array | { type: { $nin: ['json', 'vector'] } } |
$like | Like pattern | { name: { $like: '%price%' } } |
$ilike | Case insensitive like | { name: { $ilike: '%NAME%' } } |
$gt | Greater than | { created_at: { $gt: '2024-01-01' } } |
$gte | Greater than or equal | { field_order: { $gte: 10 } } |
$lt | Less than | { field_order: { $lt: 100 } } |
$lte | Less than or equal | { field_order: { $lte: 50 } } |
$null | Is null/not null | { default_value: { $null: true } } |
$exists | Field exists | { description: { $exists: true } } |
Advanced Filtering Examples
// Multiple conditions (AND)
const { data } = await client.columns.findAll("products", {
where: {
type: { $in: ["text", "email"] },
is_indexed: { $eq: true },
is_nullable: { $eq: false },
},
});
// Text pattern matching
const { data } = await client.columns.findAll("products", {
where: {
name: { $like: "%_id" }, // Columns ending with '_id'
description: { $exists: true }, // Has description
},
});
// Numeric comparisons
const { data } = await client.columns.findAll("products", {
where: {
field_order: { $gte: 1, $lte: 10 },
},
});
// Find columns with specific properties
const { data } = await client.columns.findAll("products", {
where: {
type: { $in: ["currency", "number"] }, // Numeric types
default_value: { $null: false }, // Has default value
},
});
Filter by Field Type Categories
// Text-based fields
const { data: textFields } = await client.columns.findAll("products", {
where: {
type: { $in: ["text", "long-text", "email", "phone-number", "link"] },
},
});
// Numeric fields
const { data: numericFields } = await client.columns.findAll("products", {
where: {
type: { $in: ["number", "currency"] },
},
});
// Vector fields for AI/ML
const { data: vectorFields } = await client.columns.findAll("products", {
where: {
type: { $in: ["vector", "halfvec", "sparsevec"] },
},
});
Sorting
Sort results by any column property using the sort
parameter.
Single Sort
// Sort by column name alphabetically
const { data } = await client.columns.findAll("products", {
sort: [{ field: "name", direction: "asc" }],
});
// Sort by creation date (newest first)
const { data } = await client.columns.findAll("products", {
sort: [{ field: "created_at", direction: "desc" }],
});
// Sort by field type
const { data } = await client.columns.findAll("products", {
sort: [{ field: "type", direction: "asc" }],
});
Multiple Sort Criteria
// Primary sort by type, secondary by name
const { data } = await client.columns.findAll("products", {
sort: [
{ field: "type", direction: "asc" },
{ field: "name", direction: "asc" },
],
});
// Complex sorting
const { data } = await client.columns.findAll("products", {
sort: [
{ field: "is_indexed", direction: "desc" }, // Indexed columns first
{ field: "type", direction: "asc" }, // Then by type
{ field: "created_at", direction: "desc" }, // Then by creation date
],
});
Pagination
Control the number of results using limit/offset or page-based pagination.
Limit and Offset
// Get first 10 columns
const { data } = await client.columns.findAll("products", {
limit: 10,
offset: 0,
});
// Get next 10 columns
const { data } = await client.columns.findAll("products", {
limit: 10,
offset: 10,
});
// Get columns 21-30
const { data } = await client.columns.findAll("products", {
limit: 10,
offset: 20,
});
Page-Based Pagination
// Get first page (5 columns per page)
const { data, pagination } = await client.columns.findAll("products", {
page: { page_no: 1, page_size: 5 },
});
console.log(`Page ${pagination.current_page} of ${pagination.total_pages}`);
console.log(`Showing ${data.length} of ${pagination.total_count} columns`);
// Get next page
const { data: nextPage } = await client.columns.findAll("products", {
page: { page_no: 2, page_size: 5 },
});
Pagination with Filtering
// Paginated results with filters
const { data, pagination } = await client.columns.findAll("products", {
where: { is_indexed: true },
sort: [{ field: "name", direction: "asc" }],
page: { page_no: 1, page_size: 10 },
});
console.log(`Found ${pagination.total_count} indexed columns`);
Field Selection
Select only specific fields to reduce response size and improve performance.
// Get only essential fields
const { data } = await client.columns.findAll("products", {
fields: ["name", "type", "description"],
});
// Get minimal column info
const { data } = await client.columns.findAll("products", {
fields: ["name", "type", "is_nullable"],
sort: [{ field: "name", direction: "asc" }],
});
// Get column metadata
const { data } = await client.columns.findAll("products", {
fields: ["id", "name", "created_at", "updated_at"],
});
Performance Tips
Optimize Queries
- Use field selection to reduce response size
- Apply filters to reduce the number of results
- Use appropriate pagination to avoid large result sets
- Sort by indexed fields when possible
Efficient Filtering
// Good: Filter by indexed properties
const { data } = await client.columns.findAll("products", {
where: { type: "text", is_indexed: true },
fields: ["name", "type", "description"],
limit: 20,
});
// Less efficient: Large result sets without filtering
const { data } = await client.columns.findAll("products");
Related Operations
- Using Filters - Learn how to filter columns effectively