Fix when sort is nil

This commit is contained in:
George Suntres
2026-04-25 12:44:55 -04:00
parent 374b4b22c9
commit c770d08b7f

View File

@@ -25,7 +25,7 @@ func BuildPaginationPipeline(skip, limit int64, filter bson.M, sort bson.D) mong
}
// 2. GLOBAL SORT: Sort here so both 'total' and 'data' facets use the same order
if sort != nil {
if sort != nil && len(sort) > 0 {
pipe = append(pipe, bson.D{{Key: "$sort", Value: sort}})
}