pub async fn list_instances(
pool: &Pool<MySql>,
app_id: i64,
page: i64,
per_page: i64,
) -> Result<Vec<Instance>>Expand description
Retrieves a paginated list of instances for a specific application.
This function fetches a subset of instances associated with an application, ordered by creation time with the most recent first. Pagination helps manage large datasets by retrieving only a specific “page” of results.
§Arguments
pool- Database connection pool for executing the queryapp_id- Unique identifier of the application whose instances to retrievepage- Zero-based page number (e.g., 0 for first page, 1 for second page)per_page- Number of records to fetch per page
§Returns
Ok(Vec<Instance>)- Successfully retrieved list of instancesErr(anyhow::Error)- Failed to fetch instances
§Use Cases
Common use cases include:
- Displaying paginated instances in an application dashboard
- Monitoring resource usage across an application
- Auditing instance allocation and lifecycle