Fixing page limit on cosmosdb

Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
This commit is contained in:
Ryan Lettieri 2022-09-23 14:02:01 -06:00
parent acf698ee4b
commit 0b8d937ccd
1 changed files with 8 additions and 1 deletions

View File

@ -147,9 +147,10 @@ func (q *Query) setNextParameter(val string) string {
func (q *Query) execute(client *azcosmos.ContainerClient) ([]state.QueryItem, string, error) {
opts := &azcosmos.QueryOptions{}
resultLimit := q.limit
opts.QueryParameters = append(opts.QueryParameters, q.query.parameters...)
if q.limit != 0 {
opts.PageSizeHint = int32(q.limit)
opts.PageSizeHint = int32(resultLimit)
}
if len(q.token) != 0 {
opts.ContinuationToken = q.token
@ -175,8 +176,14 @@ func (q *Query) execute(client *azcosmos.ContainerClient) ([]state.QueryItem, st
if err != nil {
return nil, "", err
}
if (len(items) + 1) > resultLimit {
break
}
items = append(items, tempItem)
}
if (len(items) + 1) > resultLimit {
break
}
}
ret := make([]state.QueryItem, len(items))