Fix when sort is nil
This commit is contained in:
@@ -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}})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user