v0.0.151
This commit is contained in:
parent
0006c6859d
commit
6589e8d5cd
@ -1,5 +1,5 @@
|
|||||||
package goext
|
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"
|
||||||
|
@ -69,7 +69,7 @@ func CreatePagination[TData any](coll *Coll[TData], token ct.CursorToken, fieldP
|
|||||||
} else if token.Mode == ct.CTMEnd {
|
} else if token.Mode == ct.CTMEnd {
|
||||||
|
|
||||||
// false
|
// 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 {
|
} else {
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ func (c *Coll[TData]) List(ctx context.Context, filter ct.Filter, pageSize *int,
|
|||||||
return nil, ct.CursorToken{}, err
|
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) {
|
for (pageSize == nil || len(entities) != *pageSize) && cursor.Next(ctx) {
|
||||||
var entry TData
|
var entry TData
|
||||||
err = cursor.Decode(&entry)
|
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)
|
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
|
return entities, ct.End(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
last := entities[len(entities)-1]
|
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
|
return entities, nextToken, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user