Raw Tables Configuration
Relevant source files
The following files were used as context for generating this wiki page:
The Raw Tables Configuration system in SeaORM Pro provides a declarative way to define how individual database entities are displayed and managed within the admin panel. These configurations are stored as TOML files and are parsed at runtime to generate the user interface for table views, filters, and CRUD (Create, Read, Update, Delete) operations.
This system allows developers to customize column visibility, input types, and access controls for each table without writing custom frontend code. The configuration files are typically located in the pro_admin/raw_tables directory and are automatically indexed by the system's configuration parser.
Sources: sea-orm-pro/src/parser.rs:26-36, pro_admin/raw_tables/product.toml
Configuration Architecture
The configuration is structured around a central JsonCfg object, which aggregates site-wide settings, dashboard layouts, and specific table configurations. Each raw table is defined by a RawTableCfg struct.
Data Flow for Configuration Loading
The following diagram illustrates how the system discovers and loads table configurations from the file system into the application state.
The ConfigParser uses the walkdir crate to iterate through the raw_tables folder, using the filename (sans extension) as the unique identifier for the table configuration.
Sources: sea-orm-pro/src/parser.rs:13-36, sea-orm-pro/src/config.rs:7-18
Core Configuration Components
A RawTableCfg is composed of several sub-sections that control different aspects of the admin interface.
Table View Configuration (table)
Defines the primary data grid behavior, including column ordering, pagination, and display density.
| Option | Type | Description |
|---|---|---|
title | String | The display name shown in the table header. |
table_size | Enum | Display density: large, middle, or small. |
page_size | usize | Number of records to display per page. |
all_columns | bool | Whether to show columns not explicitly defined in the columns list. |
order_by | Object | Default sorting field and direction (asc/desc). |
Sources: sea-orm-pro/src/config.rs:171-190, pro_admin/raw_tables/product.toml:1-26
Column Specifics (ColumnCfg)
Each column within the table can be further customized for specific presentation needs.
The input_type field is particularly important for rendering special UI elements, such as images when set to "image". Relations allow the admin panel to pull display data from linked SeaORM entities.
Sources: sea-orm-pro/src/config.rs:222-238, pro_admin/raw_tables/product.toml:13-22
CRUD and Permissions Control
The configuration explicitly defines which operations are permitted and how forms are rendered for creating or updating records.
Editor and Form Configuration
The editor, create, and update blocks manage the lifecycle of data modification.
- Editor: Enables the edit interface and defines the
title_field, which is used as the heading for individual record views. - Create/Update: Provides toggles (
enable: true/false) and lists ofhidden_columnsorreadonly_columnsto restrict user input.
Implementation Example: Product Table
The product.toml configuration demonstrates a practical implementation of these structures, specifically handling relations and specialized media types.
[table]
title = "Products"
table_size = "middle"
page_size = 30
order_by = { field = "product_id", order = "desc" }
columns = [
{ title = "ID", field = "product_id", width = 80 },
{ title = "Thumbnail", field = "thumb_nail_photo", input_type = "image", width = 120 },
{ title = "Product Category", field = "name", relation = "product_category", width = 180 },
]
all_columns = false
[update]
enable = true
readonly_columns = ["product_id"]
In this example, the thumb_nail_photo field is rendered as an image, and the product_category relation is used to fetch the category name instead of a raw ID. The product_id is kept immutable during updates.
Sources: pro_admin/raw_tables/product.toml:1-64
Server-Side Integration
The backend serves this configuration through an API endpoint (typically /admin/config). In development environments, the ConfigParser reloads the TOML files from the disk on every request to facilitate rapid prototyping. In production, the configuration is typically cached.
Sources: src/controllers/admin.rs:20-33, examples/axum_example/api/src/lib.rs:228-232
The Raw Tables Configuration system provides the necessary metadata for the SeaORM Pro admin panel to dynamically construct a functional, relation-aware database management interface solely through filesystem-based TOML definitions.