Skip to main content

export_data

Function export_data 

Source
pub async fn export_data(
    model_name: String,
    format: ExportFormat,
    site: Arc<AdminSite>,
    db: Arc<AdminDatabase>,
) -> Result<ExportResponse, ServerFnError>
Available on non-WebAssembly only.
Expand description

Export model data in various formats

Exports all records from a model table in the specified format (JSON, CSV, TSV). Returns the exported data as binary content with appropriate content type and filename.

§Server Function

This function is automatically exposed as an HTTP endpoint by the #[server_fn] macro. AdminSite and AdminDatabase dependencies are automatically injected via the DI system.

§Example

use reinhardt_admin::server::export_data;
use reinhardt_admin::types::ExportFormat;

// Client-side usage (automatically generates HTTP request)
let response = export_data("User".to_string(), ExportFormat::JSON).await?;
println!("Downloaded {}", response.filename);