v0.0.151
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user