Skip to main content

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

ParameterTypeRequiredDescription
tableNamestringName of the target table
optionsColumnQueryOptionsQuery options for filtering, sorting, pagination

ColumnQueryOptions

PropertyTypeDescription
whereRecord<string, any>Filter conditions using operators
fieldsstring[]Specific fields to include in response
sortSortOption[]Sort criteria with field and direction
limitnumberMaximum number of results to return
offsetnumberNumber 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

OperatorDescriptionExample
$eqEqual to{ type: { $eq: 'text' } }
$neNot equal to{ type: { $ne: 'text' } }
$inIn array{ type: { $in: ['text', 'email'] } }
$ninNot in array{ type: { $nin: ['json', 'vector'] } }
$likeLike pattern{ name: { $like: '%price%' } }
$ilikeCase insensitive like{ name: { $ilike: '%NAME%' } }
$gtGreater than{ created_at: { $gt: '2024-01-01' } }
$gteGreater than or equal{ field_order: { $gte: 10 } }
$ltLess than{ field_order: { $lt: 100 } }
$lteLess than or equal{ field_order: { $lte: 50 } }
$nullIs null/not null{ default_value: { $null: true } }
$existsField 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");