From 45031b05cfc83bba50ef52cc955017a02d928338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Wed, 8 Nov 2023 19:01:15 +0100 Subject: [PATCH] v0.0.303 --- goextVersion.go | 4 ++-- pagination/filter.go | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/goextVersion.go b/goextVersion.go index 5226c92..3b94920 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.302" +const GoextVersion = "0.0.303" -const GoextVersionTimestamp = "2023-11-08T18:53:02+0100" +const GoextVersionTimestamp = "2023-11-08T19:01:15+0100" diff --git a/pagination/filter.go b/pagination/filter.go index abfa678..94f35ff 100644 --- a/pagination/filter.go +++ b/pagination/filter.go @@ -9,3 +9,21 @@ type Filter interface { FilterQuery() mongo.Pipeline Pagination() (string, ct.SortDirection) } + +type dynamicFilter struct { + pipeline mongo.Pipeline + sortField string + sortDir ct.SortDirection +} + +func (d dynamicFilter) FilterQuery() mongo.Pipeline { + return d.pipeline +} + +func (d dynamicFilter) Pagination() (string, ct.SortDirection) { + return d.sortField, d.sortDir +} + +func CreateFilter(pipeline mongo.Pipeline, sortField string, sortdir ct.SortDirection) Filter { + return dynamicFilter{pipeline: pipeline, sortField: sortField, sortDir: sortdir} +}