1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package dynamodb
4
5import (
6	"context"
7	"fmt"
8	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
9	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
10	"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
11	internalEndpointDiscovery "github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery"
12	"github.com/aws/smithy-go/middleware"
13	smithyhttp "github.com/aws/smithy-go/transport/http"
14)
15
16// The Query operation finds items based on primary key values. You can query any
17// table or secondary index that has a composite primary key (a partition key and a
18// sort key). Use the KeyConditionExpression parameter to provide a specific value
19// for the partition key. The Query operation will return all of the items from the
20// table or index with that partition key value. You can optionally narrow the
21// scope of the Query operation by specifying a sort key value and a comparison
22// operator in KeyConditionExpression. To further refine the Query results, you can
23// optionally provide a FilterExpression. A FilterExpression determines which items
24// within the results should be returned to you. All of the other results are
25// discarded. A Query operation always returns a result set. If no matching items
26// are found, the result set will be empty. Queries that do not return results
27// consume the minimum number of read capacity units for that type of read
28// operation. DynamoDB calculates the number of read capacity units consumed based
29// on item size, not on the amount of data that is returned to an application. The
30// number of capacity units consumed will be the same whether you request all of
31// the attributes (the default behavior) or just some of them (using a projection
32// expression). The number will also be the same whether or not you use a
33// FilterExpression. Query results are always sorted by the sort key value. If the
34// data type of the sort key is Number, the results are returned in numeric order;
35// otherwise, the results are returned in order of UTF-8 bytes. By default, the
36// sort order is ascending. To reverse the order, set the ScanIndexForward
37// parameter to false. A single Query operation will read up to the maximum number
38// of items set (if using the Limit parameter) or a maximum of 1 MB of data and
39// then apply any filtering to the results using FilterExpression. If
40// LastEvaluatedKey is present in the response, you will need to paginate the
41// result set. For more information, see Paginating the Results
42// (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.Pagination)
43// in the Amazon DynamoDB Developer Guide. FilterExpression is applied after a
44// Query finishes, but before the results are returned. A FilterExpression cannot
45// contain partition key or sort key attributes. You need to specify those
46// attributes in the KeyConditionExpression. A Query operation can return an empty
47// result set and a LastEvaluatedKey if all the items read for the page of results
48// are filtered out. You can query a table, a local secondary index, or a global
49// secondary index. For a query on a table or on a local secondary index, you can
50// set the ConsistentRead parameter to true and obtain a strongly consistent
51// result. Global secondary indexes support eventually consistent reads only, so do
52// not specify ConsistentRead when querying a global secondary index.
53func (c *Client) Query(ctx context.Context, params *QueryInput, optFns ...func(*Options)) (*QueryOutput, error) {
54	if params == nil {
55		params = &QueryInput{}
56	}
57
58	result, metadata, err := c.invokeOperation(ctx, "Query", params, optFns, c.addOperationQueryMiddlewares)
59	if err != nil {
60		return nil, err
61	}
62
63	out := result.(*QueryOutput)
64	out.ResultMetadata = metadata
65	return out, nil
66}
67
68// Represents the input of a Query operation.
69type QueryInput struct {
70
71	// The name of the table containing the requested items.
72	//
73	// This member is required.
74	TableName *string
75
76	// This is a legacy parameter. Use ProjectionExpression instead. For more
77	// information, see AttributesToGet
78	// (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.AttributesToGet.html)
79	// in the Amazon DynamoDB Developer Guide.
80	AttributesToGet []string
81
82	// This is a legacy parameter. Use FilterExpression instead. For more information,
83	// see ConditionalOperator
84	// (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.ConditionalOperator.html)
85	// in the Amazon DynamoDB Developer Guide.
86	ConditionalOperator types.ConditionalOperator
87
88	// Determines the read consistency model: If set to true, then the operation uses
89	// strongly consistent reads; otherwise, the operation uses eventually consistent
90	// reads. Strongly consistent reads are not supported on global secondary indexes.
91	// If you query a global secondary index with ConsistentRead set to true, you will
92	// receive a ValidationException.
93	ConsistentRead *bool
94
95	// The primary key of the first item that this operation will evaluate. Use the
96	// value that was returned for LastEvaluatedKey in the previous operation. The data
97	// type for ExclusiveStartKey must be String, Number, or Binary. No set data types
98	// are allowed.
99	ExclusiveStartKey map[string]types.AttributeValue
100
101	// One or more substitution tokens for attribute names in an expression. The
102	// following are some use cases for using ExpressionAttributeNames:
103	//
104	// * To access an
105	// attribute whose name conflicts with a DynamoDB reserved word.
106	//
107	// * To create a
108	// placeholder for repeating occurrences of an attribute name in an expression.
109	//
110	// *
111	// To prevent special characters in an attribute name from being misinterpreted in
112	// an expression.
113	//
114	// Use the # character in an expression to dereference an attribute
115	// name. For example, consider the following attribute name:
116	//
117	// * Percentile
118	//
119	// The
120	// name of this attribute conflicts with a reserved word, so it cannot be used
121	// directly in an expression. (For the complete list of reserved words, see
122	// Reserved Words
123	// (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html)
124	// in the Amazon DynamoDB Developer Guide). To work around this, you could specify
125	// the following for ExpressionAttributeNames:
126	//
127	// * {"#P":"Percentile"}
128	//
129	// You could
130	// then use this substitution in an expression, as in this example:
131	//
132	// * #P =
133	// :val
134	//
135	// Tokens that begin with the : character are expression attribute values,
136	// which are placeholders for the actual value at runtime. For more information on
137	// expression attribute names, see Specifying Item Attributes
138	// (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html)
139	// in the Amazon DynamoDB Developer Guide.
140	ExpressionAttributeNames map[string]string
141
142	// One or more values that can be substituted in an expression. Use the : (colon)
143	// character in an expression to dereference an attribute value. For example,
144	// suppose that you wanted to check whether the value of the ProductStatus
145	// attribute was one of the following: Available | Backordered | Discontinued You
146	// would first need to specify ExpressionAttributeValues as follows: {
147	// ":avail":{"S":"Available"}, ":back":{"S":"Backordered"},
148	// ":disc":{"S":"Discontinued"} } You could then use these values in an expression,
149	// such as this: ProductStatus IN (:avail, :back, :disc) For more information on
150	// expression attribute values, see Specifying Conditions
151	// (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.SpecifyingConditions.html)
152	// in the Amazon DynamoDB Developer Guide.
153	ExpressionAttributeValues map[string]types.AttributeValue
154
155	// A string that contains conditions that DynamoDB applies after the Query
156	// operation, but before the data is returned to you. Items that do not satisfy the
157	// FilterExpression criteria are not returned. A FilterExpression does not allow
158	// key attributes. You cannot define a filter expression based on a partition key
159	// or a sort key. A FilterExpression is applied after the items have already been
160	// read; the process of filtering does not consume any additional read capacity
161	// units. For more information, see Filter Expressions
162	// (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html#FilteringResults)
163	// in the Amazon DynamoDB Developer Guide.
164	FilterExpression *string
165
166	// The name of an index to query. This index can be any local secondary index or
167	// global secondary index on the table. Note that if you use the IndexName
168	// parameter, you must also provide TableName.
169	IndexName *string
170
171	// The condition that specifies the key values for items to be retrieved by the
172	// Query action. The condition must perform an equality test on a single partition
173	// key value. The condition can optionally perform one of several comparison tests
174	// on a single sort key value. This allows Query to retrieve one item with a given
175	// partition key value and sort key value, or several items that have the same
176	// partition key value but different sort key values. The partition key equality
177	// test is required, and must be specified in the following format:
178	// partitionKeyName = :partitionkeyval If you also want to provide a condition for
179	// the sort key, it must be combined using AND with the condition for the sort key.
180	// Following is an example, using the = comparison operator for the sort key:
181	// partitionKeyName
182	//     =
183	//
184	//     :partitionkeyval
185	//
186	//     AND
187	//
188	//     sortKeyName
189	//
190	//
191	// =
192	//
193	// :sortkeyval Valid comparisons for the sort key condition are as follows:
194	//
195	// *
196	// sortKeyName=:sortkeyval - true if the sort key value is equal to :sortkeyval.
197	//
198	// *
199	// sortKeyName<:sortkeyval - true if the sort key value is less than
200	// :sortkeyval.
201	//
202	// * sortKeyName<=:sortkeyval - true if the sort key value is less
203	// than or equal to :sortkeyval.
204	//
205	// * sortKeyName>:sortkeyval - true if the sort key
206	// value is greater than :sortkeyval.
207	//
208	// * sortKeyName>= :sortkeyval - true if the
209	// sort key value is greater than or equal to :sortkeyval.
210	//
211	// *
212	// sortKeyNameBETWEEN:sortkeyval1AND:sortkeyval2 - true if the sort key value is
213	// greater than or equal to :sortkeyval1, and less than or equal to
214	// :sortkeyval2.
215	//
216	// * begins_with (sortKeyName, :sortkeyval) - true if the sort key
217	// value begins with a particular operand. (You cannot use this function with a
218	// sort key that is of type Number.) Note that the function name begins_with is
219	// case-sensitive.
220	//
221	// Use the ExpressionAttributeValues parameter to replace tokens
222	// such as :partitionval and :sortval with actual values at runtime. You can
223	// optionally use the ExpressionAttributeNames parameter to replace the names of
224	// the partition key and sort key with placeholder tokens. This option might be
225	// necessary if an attribute name conflicts with a DynamoDB reserved word. For
226	// example, the following KeyConditionExpression parameter causes an error because
227	// Size is a reserved word:
228	//
229	// * Size = :myval
230	//
231	// To work around this, define a
232	// placeholder (such a #S) to represent the attribute name Size.
233	// KeyConditionExpression then is as follows:
234	//
235	// * #S = :myval
236	//
237	// For a list of
238	// reserved words, see Reserved Words
239	// (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html)
240	// in the Amazon DynamoDB Developer Guide. For more information on
241	// ExpressionAttributeNames and ExpressionAttributeValues, see Using Placeholders
242	// for Attribute Names and Values
243	// (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ExpressionPlaceholders.html)
244	// in the Amazon DynamoDB Developer Guide.
245	KeyConditionExpression *string
246
247	// This is a legacy parameter. Use KeyConditionExpression instead. For more
248	// information, see KeyConditions
249	// (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.KeyConditions.html)
250	// in the Amazon DynamoDB Developer Guide.
251	KeyConditions map[string]types.Condition
252
253	// The maximum number of items to evaluate (not necessarily the number of matching
254	// items). If DynamoDB processes the number of items up to the limit while
255	// processing the results, it stops the operation and returns the matching values
256	// up to that point, and a key in LastEvaluatedKey to apply in a subsequent
257	// operation, so that you can pick up where you left off. Also, if the processed
258	// dataset size exceeds 1 MB before DynamoDB reaches this limit, it stops the
259	// operation and returns the matching values up to the limit, and a key in
260	// LastEvaluatedKey to apply in a subsequent operation to continue the operation.
261	// For more information, see Query and Scan
262	// (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html)
263	// in the Amazon DynamoDB Developer Guide.
264	Limit *int32
265
266	// A string that identifies one or more attributes to retrieve from the table.
267	// These attributes can include scalars, sets, or elements of a JSON document. The
268	// attributes in the expression must be separated by commas. If no attribute names
269	// are specified, then all attributes will be returned. If any of the requested
270	// attributes are not found, they will not appear in the result. For more
271	// information, see Accessing Item Attributes
272	// (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html)
273	// in the Amazon DynamoDB Developer Guide.
274	ProjectionExpression *string
275
276	// This is a legacy parameter. Use FilterExpression instead. For more information,
277	// see QueryFilter
278	// (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.QueryFilter.html)
279	// in the Amazon DynamoDB Developer Guide.
280	QueryFilter map[string]types.Condition
281
282	// Determines the level of detail about provisioned throughput consumption that is
283	// returned in the response:
284	//
285	// * INDEXES - The response includes the aggregate
286	// ConsumedCapacity for the operation, together with ConsumedCapacity for each
287	// table and secondary index that was accessed. Note that some operations, such as
288	// GetItem and BatchGetItem, do not access any indexes at all. In these cases,
289	// specifying INDEXES will only return ConsumedCapacity information for
290	// table(s).
291	//
292	// * TOTAL - The response includes only the aggregate ConsumedCapacity
293	// for the operation.
294	//
295	// * NONE - No ConsumedCapacity details are included in the
296	// response.
297	ReturnConsumedCapacity types.ReturnConsumedCapacity
298
299	// Specifies the order for index traversal: If true (default), the traversal is
300	// performed in ascending order; if false, the traversal is performed in descending
301	// order. Items with the same partition key value are stored in sorted order by
302	// sort key. If the sort key data type is Number, the results are stored in numeric
303	// order. For type String, the results are stored in order of UTF-8 bytes. For type
304	// Binary, DynamoDB treats each byte of the binary data as unsigned. If
305	// ScanIndexForward is true, DynamoDB returns the results in the order in which
306	// they are stored (by sort key value). This is the default behavior. If
307	// ScanIndexForward is false, DynamoDB reads the results in reverse order by sort
308	// key value, and then returns the results to the client.
309	ScanIndexForward *bool
310
311	// The attributes to be returned in the result. You can retrieve all item
312	// attributes, specific item attributes, the count of matching items, or in the
313	// case of an index, some or all of the attributes projected into the index.
314	//
315	// *
316	// ALL_ATTRIBUTES - Returns all of the item attributes from the specified table or
317	// index. If you query a local secondary index, then for each matching item in the
318	// index, DynamoDB fetches the entire item from the parent table. If the index is
319	// configured to project all item attributes, then all of the data can be obtained
320	// from the local secondary index, and no fetching is required.
321	//
322	// *
323	// ALL_PROJECTED_ATTRIBUTES - Allowed only when querying an index. Retrieves all
324	// attributes that have been projected into the index. If the index is configured
325	// to project all attributes, this return value is equivalent to specifying
326	// ALL_ATTRIBUTES.
327	//
328	// * COUNT - Returns the number of matching items, rather than the
329	// matching items themselves.
330	//
331	// * SPECIFIC_ATTRIBUTES - Returns only the attributes
332	// listed in AttributesToGet. This return value is equivalent to specifying
333	// AttributesToGet without specifying any value for Select. If you query or scan a
334	// local secondary index and request only attributes that are projected into that
335	// index, the operation will read only the index and not the table. If any of the
336	// requested attributes are not projected into the local secondary index, DynamoDB
337	// fetches each of these attributes from the parent table. This extra fetching
338	// incurs additional throughput cost and latency. If you query or scan a global
339	// secondary index, you can only request attributes that are projected into the
340	// index. Global secondary index queries cannot fetch attributes from the parent
341	// table.
342	//
343	// If neither Select nor AttributesToGet are specified, DynamoDB defaults
344	// to ALL_ATTRIBUTES when accessing a table, and ALL_PROJECTED_ATTRIBUTES when
345	// accessing an index. You cannot use both Select and AttributesToGet together in a
346	// single request, unless the value for Select is SPECIFIC_ATTRIBUTES. (This usage
347	// is equivalent to specifying AttributesToGet without any value for Select.) If
348	// you use the ProjectionExpression parameter, then the value for Select can only
349	// be SPECIFIC_ATTRIBUTES. Any other value for Select will return an error.
350	Select types.Select
351
352	noSmithyDocumentSerde
353}
354
355// Represents the output of a Query operation.
356type QueryOutput struct {
357
358	// The capacity units consumed by the Query operation. The data returned includes
359	// the total provisioned throughput consumed, along with statistics for the table
360	// and any indexes involved in the operation. ConsumedCapacity is only returned if
361	// the ReturnConsumedCapacity parameter was specified. For more information, see
362	// Provisioned Throughput
363	// (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ProvisionedThroughputIntro.html)
364	// in the Amazon DynamoDB Developer Guide.
365	ConsumedCapacity *types.ConsumedCapacity
366
367	// The number of items in the response. If you used a QueryFilter in the request,
368	// then Count is the number of items returned after the filter was applied, and
369	// ScannedCount is the number of matching items before the filter was applied. If
370	// you did not use a filter in the request, then Count and ScannedCount are the
371	// same.
372	Count int32
373
374	// An array of item attributes that match the query criteria. Each element in this
375	// array consists of an attribute name and the value for that attribute.
376	Items []map[string]types.AttributeValue
377
378	// The primary key of the item where the operation stopped, inclusive of the
379	// previous result set. Use this value to start a new operation, excluding this
380	// value in the new request. If LastEvaluatedKey is empty, then the "last page" of
381	// results has been processed and there is no more data to be retrieved. If
382	// LastEvaluatedKey is not empty, it does not necessarily mean that there is more
383	// data in the result set. The only way to know when you have reached the end of
384	// the result set is when LastEvaluatedKey is empty.
385	LastEvaluatedKey map[string]types.AttributeValue
386
387	// The number of items evaluated, before any QueryFilter is applied. A high
388	// ScannedCount value with few, or no, Count results indicates an inefficient Query
389	// operation. For more information, see Count and ScannedCount
390	// (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html#Count)
391	// in the Amazon DynamoDB Developer Guide. If you did not use a filter in the
392	// request, then ScannedCount is the same as Count.
393	ScannedCount int32
394
395	// Metadata pertaining to the operation's result.
396	ResultMetadata middleware.Metadata
397
398	noSmithyDocumentSerde
399}
400
401func (c *Client) addOperationQueryMiddlewares(stack *middleware.Stack, options Options) (err error) {
402	err = stack.Serialize.Add(&awsAwsjson10_serializeOpQuery{}, middleware.After)
403	if err != nil {
404		return err
405	}
406	err = stack.Deserialize.Add(&awsAwsjson10_deserializeOpQuery{}, middleware.After)
407	if err != nil {
408		return err
409	}
410	if err = addSetLoggerMiddleware(stack, options); err != nil {
411		return err
412	}
413	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
414		return err
415	}
416	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
417		return err
418	}
419	if err = addResolveEndpointMiddleware(stack, options); err != nil {
420		return err
421	}
422	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
423		return err
424	}
425	if err = addRetryMiddlewares(stack, options); err != nil {
426		return err
427	}
428	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
429		return err
430	}
431	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
432		return err
433	}
434	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
435		return err
436	}
437	if err = addClientUserAgent(stack); err != nil {
438		return err
439	}
440	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
441		return err
442	}
443	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
444		return err
445	}
446	if err = addOpQueryDiscoverEndpointMiddleware(stack, options, c); err != nil {
447		return err
448	}
449	if err = addOpQueryValidationMiddleware(stack); err != nil {
450		return err
451	}
452	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opQuery(options.Region), middleware.Before); err != nil {
453		return err
454	}
455	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
456		return err
457	}
458	if err = addResponseErrorMiddleware(stack); err != nil {
459		return err
460	}
461	if err = addValidateResponseChecksum(stack, options); err != nil {
462		return err
463	}
464	if err = addAcceptEncodingGzip(stack, options); err != nil {
465		return err
466	}
467	if err = addRequestResponseLogging(stack, options); err != nil {
468		return err
469	}
470	return nil
471}
472
473func addOpQueryDiscoverEndpointMiddleware(stack *middleware.Stack, o Options, c *Client) error {
474	return stack.Serialize.Insert(&internalEndpointDiscovery.DiscoverEndpoint{
475		Options: []func(*internalEndpointDiscovery.DiscoverEndpointOptions){
476			func(opt *internalEndpointDiscovery.DiscoverEndpointOptions) {
477				opt.DisableHTTPS = o.EndpointOptions.DisableHTTPS
478				opt.Logger = o.Logger
479			},
480		},
481		DiscoverOperation:            c.fetchOpQueryDiscoverEndpoint,
482		EndpointDiscoveryEnableState: o.EndpointDiscovery.EnableEndpointDiscovery,
483		EndpointDiscoveryRequired:    false,
484	}, "ResolveEndpoint", middleware.After)
485}
486
487func (c *Client) fetchOpQueryDiscoverEndpoint(ctx context.Context, input interface{}, optFns ...func(*internalEndpointDiscovery.DiscoverEndpointOptions)) (internalEndpointDiscovery.WeightedAddress, error) {
488	in, ok := input.(*QueryInput)
489	if !ok {
490		return internalEndpointDiscovery.WeightedAddress{}, fmt.Errorf("unknown input type %T", input)
491	}
492	_ = in
493
494	identifierMap := make(map[string]string, 0)
495
496	key := fmt.Sprintf("DynamoDB.%v", identifierMap)
497
498	if v, ok := c.endpointCache.Get(key); ok {
499		return v, nil
500	}
501
502	discoveryOperationInput := &DescribeEndpointsInput{}
503
504	opt := internalEndpointDiscovery.DiscoverEndpointOptions{}
505	for _, fn := range optFns {
506		fn(&opt)
507	}
508
509	go c.handleEndpointDiscoveryFromService(ctx, discoveryOperationInput, key, opt)
510	return internalEndpointDiscovery.WeightedAddress{}, nil
511}
512
513// QueryAPIClient is a client that implements the Query operation.
514type QueryAPIClient interface {
515	Query(context.Context, *QueryInput, ...func(*Options)) (*QueryOutput, error)
516}
517
518var _ QueryAPIClient = (*Client)(nil)
519
520// QueryPaginatorOptions is the paginator options for Query
521type QueryPaginatorOptions struct {
522	// The maximum number of items to evaluate (not necessarily the number of matching
523	// items). If DynamoDB processes the number of items up to the limit while
524	// processing the results, it stops the operation and returns the matching values
525	// up to that point, and a key in LastEvaluatedKey to apply in a subsequent
526	// operation, so that you can pick up where you left off. Also, if the processed
527	// dataset size exceeds 1 MB before DynamoDB reaches this limit, it stops the
528	// operation and returns the matching values up to the limit, and a key in
529	// LastEvaluatedKey to apply in a subsequent operation to continue the operation.
530	// For more information, see Query and Scan
531	// (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html)
532	// in the Amazon DynamoDB Developer Guide.
533	Limit int32
534}
535
536// QueryPaginator is a paginator for Query
537type QueryPaginator struct {
538	options   QueryPaginatorOptions
539	client    QueryAPIClient
540	params    *QueryInput
541	nextToken map[string]types.AttributeValue
542	firstPage bool
543}
544
545// NewQueryPaginator returns a new QueryPaginator
546func NewQueryPaginator(client QueryAPIClient, params *QueryInput, optFns ...func(*QueryPaginatorOptions)) *QueryPaginator {
547	if params == nil {
548		params = &QueryInput{}
549	}
550
551	options := QueryPaginatorOptions{}
552	if params.Limit != nil {
553		options.Limit = *params.Limit
554	}
555
556	for _, fn := range optFns {
557		fn(&options)
558	}
559
560	return &QueryPaginator{
561		options:   options,
562		client:    client,
563		params:    params,
564		firstPage: true,
565	}
566}
567
568// HasMorePages returns a boolean indicating whether more pages are available
569func (p *QueryPaginator) HasMorePages() bool {
570	return p.firstPage || p.nextToken != nil
571}
572
573// NextPage retrieves the next Query page.
574func (p *QueryPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*QueryOutput, error) {
575	if !p.HasMorePages() {
576		return nil, fmt.Errorf("no more pages available")
577	}
578
579	params := *p.params
580	params.ExclusiveStartKey = p.nextToken
581
582	var limit *int32
583	if p.options.Limit > 0 {
584		limit = &p.options.Limit
585	}
586	params.Limit = limit
587
588	result, err := p.client.Query(ctx, &params, optFns...)
589	if err != nil {
590		return nil, err
591	}
592	p.firstPage = false
593
594	prevToken := p.nextToken
595	p.nextToken = result.LastEvaluatedKey
596
597	_ = prevToken
598
599	return result, nil
600}
601
602func newServiceMetadataMiddleware_opQuery(region string) *awsmiddleware.RegisterServiceMetadata {
603	return &awsmiddleware.RegisterServiceMetadata{
604		Region:        region,
605		ServiceID:     ServiceID,
606		SigningName:   "dynamodb",
607		OperationName: "Query",
608	}
609}
610