pagination optimization
This commit is contained in:
@@ -40,6 +40,14 @@ func collectionName() string {
|
||||
return "tenders"
|
||||
}
|
||||
|
||||
// tenderSearchListProjection excludes large fields not needed for list/search API payloads.
|
||||
func tenderSearchListProjection() bson.M {
|
||||
return bson.M{
|
||||
"content_xml": 0,
|
||||
"document_summaries": 0,
|
||||
}
|
||||
}
|
||||
|
||||
// tenderRepository implements TenderRepository interface using MongoDB ORM
|
||||
type tenderRepository struct {
|
||||
ormRepo orm.Repository[Tender]
|
||||
@@ -332,6 +340,7 @@ func (r *tenderRepository) Search(ctx context.Context, form *SearchForm, paginat
|
||||
Limit(pagination.Limit).
|
||||
Skip(pagination.Offset).
|
||||
SortBy(sort, sortOrder).
|
||||
Projection(tenderSearchListProjection()).
|
||||
Build()
|
||||
|
||||
result, err := r.ormRepo.FindAll(ctx, filter, paginationBuilder)
|
||||
|
||||
Reference in New Issue
Block a user