goext/pagination/filter.go
Mike Schwörer f1f91f4cfa
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m25s
v0.0.372 sq.Paginate
2024-01-13 21:36:47 +01:00

29 lines
514 B
Go

package pagination
import (
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
)
type MongoFilter 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) MongoFilter {
return dynamicFilter{pipeline: pipeline, sort: sort}
}