diff --git a/pipeline.go b/pipeline.go index e4ba149..06d462f 100644 --- a/pipeline.go +++ b/pipeline.go @@ -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}}) }