diff --git a/goextVersion.go b/goextVersion.go index fc9ff0f..3a5d188 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.150" +const GoextVersion = "0.0.151" -const GoextVersionTimestamp = "2023-06-07T17:48:36+0200" +const GoextVersionTimestamp = "2023-06-07T17:57:03+0200" diff --git a/wmo/pagination.go b/wmo/pagination.go index afeb0eb..aebb044 100644 --- a/wmo/pagination.go +++ b/wmo/pagination.go @@ -69,7 +69,7 @@ func CreatePagination[TData any](coll *Coll[TData], token ct.CursorToken, fieldP } else if token.Mode == ct.CTMEnd { // false - pipeline = append(pipeline, bson.D{{Key: "$match", Value: bson.M{"$eq": bson.A{"1", "0"}}}}) + pipeline = append(pipeline, bson.D{{Key: "$match", Value: bson.M{"$expr": bson.M{"$eq": bson.A{"1", "0"}}}}}) } else { diff --git a/wmo/queryList.go b/wmo/queryList.go index 81d8618..bbb9c84 100644 --- a/wmo/queryList.go +++ b/wmo/queryList.go @@ -37,7 +37,7 @@ func (c *Coll[TData]) List(ctx context.Context, filter ct.Filter, pageSize *int, return nil, ct.CursorToken{}, err } - entities := make([]TData, 0, cursor.RemainingBatchLength()+1) + entities := make([]TData, 0, cursor.RemainingBatchLength()) for (pageSize == nil || len(entities) != *pageSize) && cursor.Next(ctx) { var entry TData err = cursor.Decode(&entry) @@ -47,13 +47,16 @@ func (c *Coll[TData]) List(ctx context.Context, filter ct.Filter, pageSize *int, entities = append(entities, entry) } - if pageSize == nil || len(entities) <= *pageSize || !cursor.TryNext(ctx) { + if pageSize == nil || len(entities) < *pageSize || !cursor.TryNext(ctx) { return entities, ct.End(), nil } last := entities[len(entities)-1] - nextToken, _ := c.createToken(sortPrimary, sortDirPrimary, sortSecondary, sortDirSecondary, last, pageSize) + nextToken, err := c.createToken(sortPrimary, sortDirPrimary, sortSecondary, sortDirSecondary, last, pageSize) + if err != nil { + return nil, ct.CursorToken{}, err + } return entities, nextToken, nil }