goext/pagination/filter.go
Mike Schwörer afcc89bf9e
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m20s
v0.0.307
2023-11-09 10:00:01 +01:00

29 lines
504 B
Go

package pagination
import (
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
)
type Filter interface {
FilterQuery() mongo.Pipeline
Sort() bson.D
}
type dynamicFilter struct {
pipeline mongo.Pipeline
sort bson.D
}
func (d dynamicFilter) FilterQuery() mongo.Pipeline {
return d.pipeline
}
func (d dynamicFilter) Sort() bson.D {
return d.sort
}
func CreateFilter(pipeline mongo.Pipeline, sort bson.D) Filter {
return dynamicFilter{pipeline: pipeline, sort: sort}
}