v0.0.307
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m20s

This commit is contained in:
Mike Schwörer 2023-11-09 10:00:01 +01:00
parent 1672e8f8fd
commit afcc89bf9e
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 10 additions and 11 deletions

View File

@ -1,5 +1,5 @@
package goext package goext
const GoextVersion = "0.0.306" const GoextVersion = "0.0.307"
const GoextVersionTimestamp = "2023-11-09T09:36:41+0100" const GoextVersionTimestamp = "2023-11-09T10:00:01+0100"

View File

@ -1,29 +1,28 @@
package pagination package pagination
import ( import (
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
ct "gogs.mikescher.com/BlackForestBytes/goext/cursortoken"
) )
type Filter interface { type Filter interface {
FilterQuery() mongo.Pipeline FilterQuery() mongo.Pipeline
Pagination() (string, ct.SortDirection) Sort() bson.D
} }
type dynamicFilter struct { type dynamicFilter struct {
pipeline mongo.Pipeline pipeline mongo.Pipeline
sortField string sort bson.D
sortDir ct.SortDirection
} }
func (d dynamicFilter) FilterQuery() mongo.Pipeline { func (d dynamicFilter) FilterQuery() mongo.Pipeline {
return d.pipeline return d.pipeline
} }
func (d dynamicFilter) Pagination() (string, ct.SortDirection) { func (d dynamicFilter) Sort() bson.D {
return d.sortField, d.sortDir return d.sort
} }
func CreateFilter(pipeline mongo.Pipeline, sortField string, sortdir ct.SortDirection) Filter { func CreateFilter(pipeline mongo.Pipeline, sort bson.D) Filter {
return dynamicFilter{pipeline: pipeline, sortField: sortField, sortDir: sortdir} return dynamicFilter{pipeline: pipeline, sort: sort}
} }