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

This commit is contained in:
Mike Schwörer 2024-06-14 17:24:59 +02:00
parent 94a7bf250d
commit fc4bed4b9f
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
5 changed files with 17 additions and 15 deletions

View File

@ -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)
}

View File

@ -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"

View File

@ -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
}

View File

@ -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{}

View File

@ -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 {