// QueryIterator iterates all results of a query
QueryIterator iterates all results of a query
// QueryIterator iterates all results of a query
func (c *Client) QueryIterator(ctx context.Context, input *dynamodb.QueryInput, fn func(output *dynamodb.QueryOutput) error) error {
	in2 := *input
	hasLimit := input.Limit != nil
	var limit int
	if hasLimit {
		limit = int(*input.Limit)
		in2.Limit = nil
	}
	seen := 0
	var pageError error
	err := c.DynamoDB.QueryPagesWithContext(ctx, &in2, func(output *dynamodb.QueryOutput, b bool) bool {
		if hasLimit {
			var added, broke bool
			var items []map[string]*dynamodb.AttributeValue
			for _, i := range output.Items {
				seen++
				if seen > limit {
					broke = true
					break
				}
				added = true
				items = append(items, i)
			}
			if seen > 0 && !added && broke {
				return false
			}
			output.Items = items
		}
		pageError = fn(output)
		return pageError == nil
	})
	if err != nil {
		return err
	}
	if pageError != nil {
		return pageError
	}
	return nil
}
func ( c * Client ) QueryIterator ( ctx context . Context , input * dynamodb . QueryInput , fn func ( output * dynamodb . QueryOutput ) error ) error { in2 := * input hasLimit := input . Limit != nil var limit int if hasLimit { limit = int ( * input . Limit ) in2 . Limit = nil } seen := 0 var pageError error err := c . DynamoDB . QueryPagesWithContext ( ctx , & in2 , func ( output * dynamodb . QueryOutput , b bool ) bool { if hasLimit { var added , broke bool var items [ ] map [ string ] * dynamodb . AttributeValue for _ , i := range output . Items { seen ++ if seen > limit { broke = true break } added = true items = append ( items , i ) } if seen > 0 && ! added && broke { return false } output . Items = items } pageError = fn ( output ) return pageError == nil } ) if err != nil { return err } if pageError != nil { return pageError } return nil }
QueryIterator iterates all results of a query
QueryIterator iterates all results of a query
//TODO: clean this up