From c770d08b7f28e53d095a72b3fbe28184972ba083 Mon Sep 17 00:00:00 2001 From: George Suntres Date: Sat, 25 Apr 2026 12:44:55 -0400 Subject: [PATCH] Fix when sort is nil --- pipeline.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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}}) }