v0.0.308
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m20s
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m20s
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
ct "gogs.mikescher.com/BlackForestBytes/goext/cursortoken"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/exerr"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||
pag "gogs.mikescher.com/BlackForestBytes/goext/pagination"
|
||||
@@ -21,18 +20,15 @@ func (c *Coll[TData]) Paginate(ctx context.Context, filter pag.Filter, page int,
|
||||
|
||||
pipelineSort := mongo.Pipeline{}
|
||||
pipelineFilter := mongo.Pipeline{}
|
||||
pf1 := "_id"
|
||||
pd1 := ct.SortASC
|
||||
sort := bson.D{}
|
||||
|
||||
if filter != nil {
|
||||
pipelineFilter = filter.FilterQuery()
|
||||
pf1, pd1 = filter.Pagination()
|
||||
sort = filter.Sort()
|
||||
}
|
||||
|
||||
if pd1 == ct.SortASC {
|
||||
pipelineSort = append(pipelineSort, bson.D{{Key: "$sort", Value: bson.D{{Key: pf1, Value: +1}}}})
|
||||
} else if pd1 == ct.SortDESC {
|
||||
pipelineSort = append(pipelineSort, bson.D{{Key: "$sort", Value: bson.D{{Key: pf1, Value: -1}}}})
|
||||
if len(sort) != 0 {
|
||||
pipelineSort = append(pipelineSort, bson.D{{Key: "$sort", Value: sort}})
|
||||
}
|
||||
|
||||
pipelinePaginate := mongo.Pipeline{}
|
||||
|
Reference in New Issue
Block a user