Skip to content

Add Pagination and Filtering to Asset List Endpoint #30

Description

@parkerwinner

Summary

Add pagination and filtering to the GET /api/v1/assets endpoint in the Go backend (in backend/handlers/assets.go). This addition is key for the tokenized RWA marketplace, as it handles large asset lists by supporting query params for page, limit, filters (e.g., type=real_estate, status=active), and sorting (e.g., by value desc), querying PostgreSQL efficiently with GORM, and returning paginated JSON with metadata (total, next_page), improving UX and performance.
The pagination/filtering should include:

Query Params: page (int, default 1), limit (int, default 20), type (string), status (string), sort (string like "value:desc").
Logic Flow:
Parse params: Use gin.Query, validate ranges.
Build query: GORM chain like db.Where("type = ?", typ).Order(sort).Offset((page-1)*limit).Limit(limit).Find(&assets).
Count total: Separate db.Count for pagination meta.
Response: JSON { "data": assets, "pagination": { "total": count, "page": page, "limit": limit } }.
Defaults: Safe fallbacks.
Caching: Optional Redis for filtered lists.
Edge cases: Empty results, invalid params.

Error Handling: 400 for invalid params.
Security Considerations: Prevent SQL injection via GORM.
Integration: With DB for large datasets.
Future-Proofing: Cursor-based for infinite scroll.

Test with queries: Unit for parsing, integration with seeded DB.

Branch for Development
feature/add-pagination-filtering

PR Title
feat: Add Pagination and Filtering to Asset List Endpoint for Scalability

Additional Note

Checkout from main: git checkout -b feature/add-pagination-filtering
Run go test ./handlers and test with query strings.
PR: Handler updates, tests, param examples, and meta structure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveIssues in the Stellar wave programhelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions