v0.0.140
This commit is contained in:
parent
5fb2f8a312
commit
b16d5152c7
@ -6,5 +6,5 @@ import (
|
|||||||
|
|
||||||
type Filter interface {
|
type Filter interface {
|
||||||
FilterQuery() mongo.Pipeline
|
FilterQuery() mongo.Pipeline
|
||||||
Pagination() (string, SortDirection, *string, *SortDirection)
|
Pagination() (string, SortDirection, string, SortDirection)
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
package wmo
|
package wmo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
|
)
|
||||||
|
|
||||||
func (c *Coll[TData]) DeleteOne(ctx context.Context, id EntityID) error {
|
func (c *Coll[TData]) DeleteOne(ctx context.Context, id EntityID) error {
|
||||||
_, err := c.coll.DeleteOne(ctx, bson.M{"_id": id})
|
_, err := c.coll.DeleteOne(ctx, bson.M{"_id": id})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -13,7 +13,17 @@ func (c *Coll[TData]) List(ctx context.Context, filter ct.Filter, pageSize *int,
|
|||||||
|
|
||||||
pipeline := filter.FilterQuery()
|
pipeline := filter.FilterQuery()
|
||||||
|
|
||||||
sortPrimary, sortDirPrimary, sortSecondary, sortDirSecondary := filter.Pagination()
|
pf1, pd1, pf2, pd2 := filter.Pagination()
|
||||||
|
|
||||||
|
sortPrimary := pf1
|
||||||
|
sortDirPrimary := pd1
|
||||||
|
sortSecondary := &pf2
|
||||||
|
sortDirSecondary := &pd2
|
||||||
|
|
||||||
|
if pf1 == pf2 {
|
||||||
|
sortSecondary = nil
|
||||||
|
sortDirSecondary = nil
|
||||||
|
}
|
||||||
|
|
||||||
paginationPipeline, err := CreatePagination(c, inTok, sortPrimary, sortDirPrimary, sortSecondary, sortDirSecondary, pageSize)
|
paginationPipeline, err := CreatePagination(c, inTok, sortPrimary, sortDirPrimary, sortSecondary, sortDirSecondary, pageSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user