v0.0.473 add ctx to wmo.FilterQuery|Sort|Pagination
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m23s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m23s
This commit is contained in:
parent
94a7bf250d
commit
fc4bed4b9f
@ -1,14 +1,15 @@
|
||||
package cursortoken
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
)
|
||||
|
||||
type RawFilter interface {
|
||||
FilterQuery() mongo.Pipeline
|
||||
FilterQuery(ctx context.Context) mongo.Pipeline
|
||||
}
|
||||
|
||||
type Filter interface {
|
||||
FilterQuery() mongo.Pipeline
|
||||
Pagination() (string, SortDirection, string, SortDirection)
|
||||
FilterQuery(ctx context.Context) mongo.Pipeline
|
||||
Pagination(ctx context.Context) (string, SortDirection, string, SortDirection)
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
package goext
|
||||
|
||||
const GoextVersion = "0.0.472"
|
||||
const GoextVersion = "0.0.473"
|
||||
|
||||
const GoextVersionTimestamp = "2024-06-14T14:56:41+0200"
|
||||
const GoextVersionTimestamp = "2024-06-14T17:24:59+0200"
|
||||
|
@ -1,13 +1,14 @@
|
||||
package pagination
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
)
|
||||
|
||||
type MongoFilter interface {
|
||||
FilterQuery() mongo.Pipeline
|
||||
Sort() bson.D
|
||||
FilterQuery(ctx context.Context) mongo.Pipeline
|
||||
Sort(ctx context.Context) bson.D
|
||||
}
|
||||
|
||||
type dynamicFilter struct {
|
||||
@ -15,11 +16,11 @@ type dynamicFilter struct {
|
||||
sort bson.D
|
||||
}
|
||||
|
||||
func (d dynamicFilter) FilterQuery() mongo.Pipeline {
|
||||
func (d dynamicFilter) FilterQuery(ctx context.Context) mongo.Pipeline {
|
||||
return d.pipeline
|
||||
}
|
||||
|
||||
func (d dynamicFilter) Sort() bson.D {
|
||||
func (d dynamicFilter) Sort(ctx context.Context) bson.D {
|
||||
return d.sort
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ func (c *Coll[TData]) List(ctx context.Context, filter ct.Filter, pageSize *int,
|
||||
pd2 := ct.SortASC
|
||||
|
||||
if filter != nil {
|
||||
pipeline = filter.FilterQuery()
|
||||
pf1, pd1, pf2, pd2 = filter.Pagination()
|
||||
pipeline = filter.FilterQuery(ctx)
|
||||
pf1, pd1, pf2, pd2 = filter.Pagination(ctx)
|
||||
}
|
||||
|
||||
sortPrimary := pf1
|
||||
@ -109,7 +109,7 @@ func (c *Coll[TData]) Count(ctx context.Context, filter ct.RawFilter) (int64, er
|
||||
Count int64 `bson:"c"`
|
||||
}
|
||||
|
||||
pipeline := filter.FilterQuery()
|
||||
pipeline := filter.FilterQuery(ctx)
|
||||
|
||||
pipeline = append(pipeline, bson.D{{Key: "$count", Value: "c"}})
|
||||
|
||||
@ -152,7 +152,7 @@ func (c *Coll[TData]) ListAllIDs(ctx context.Context, filter ct.RawFilter) ([]st
|
||||
pipelineFilter := mongo.Pipeline{}
|
||||
|
||||
if filter != nil {
|
||||
pipelineFilter = filter.FilterQuery()
|
||||
pipelineFilter = filter.FilterQuery(ctx)
|
||||
}
|
||||
|
||||
extrModPipelineResolved := mongo.Pipeline{}
|
||||
|
@ -23,8 +23,8 @@ func (c *Coll[TData]) Paginate(ctx context.Context, filter pag.MongoFilter, page
|
||||
sort := bson.D{}
|
||||
|
||||
if filter != nil {
|
||||
pipelineFilter = filter.FilterQuery()
|
||||
sort = filter.Sort()
|
||||
pipelineFilter = filter.FilterQuery(ctx)
|
||||
sort = filter.Sort(ctx)
|
||||
}
|
||||
|
||||
if len(sort) != 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user