scan method
Retrieves one or more items and its attributes by performing a full scan of a table.
Provide a ScanFilter
to get more specific results.
May throw ProvisionedThroughputExceededException. May throw ResourceNotFoundException. May throw RequestLimitExceeded. May throw InternalServerError.
Parameter tableName
:
The name of the table in which you want to scan. Allowed characters are
a-z
, A-Z
, 0-9
, _
(underscore), -
(hyphen) and .
(period).
Parameter count
:
If set to true
, Amazon DynamoDB returns a total number of
items for the Scan
operation, even if the operation has no
matching items for the assigned filter. Do not set Count
to
true
while providing a list of AttributesToGet
,
otherwise Amazon DynamoDB returns a validation error.
Parameter exclusiveStartKey
:
Primary key of the item from which to continue an earlier scan. An earlier
scan might provide this value if that scan operation was interrupted
before scanning the entire table; either because of the result set size or
the Limit
parameter. The LastEvaluatedKey
can be
passed back in a new scan request to continue the operation from that
point.
Parameter limit
:
The maximum number of items to return. If Amazon DynamoDB hits this limit
while scanning the table, it stops the scan and returns the matching
values up to the limit, and a LastEvaluatedKey
to apply in a
subsequent operation to continue the scan. Also, if the scanned data set
size exceeds 1 MB before Amazon DynamoDB hits this limit, it stops the
scan and returns the matching values up to the limit, and a
LastEvaluatedKey
to apply in a subsequent operation to
continue the scan.
Parameter scanFilter
:
Evaluates the scan results and returns only the desired values.
Implementation
Future<ScanOutput> scan({
required String tableName,
List<String>? attributesToGet,
bool? count,
Key? exclusiveStartKey,
int? limit,
Map<String, Condition>? scanFilter,
}) async {
ArgumentError.checkNotNull(tableName, 'tableName');
_s.validateStringLength(
'tableName',
tableName,
3,
255,
isRequired: true,
);
_s.validateNumRange(
'limit',
limit,
1,
1152921504606846976,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.0',
'X-Amz-Target': 'DynamoDB_20111205.Scan'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'TableName': tableName,
if (attributesToGet != null) 'AttributesToGet': attributesToGet,
if (count != null) 'Count': count,
if (exclusiveStartKey != null) 'ExclusiveStartKey': exclusiveStartKey,
if (limit != null) 'Limit': limit,
if (scanFilter != null) 'ScanFilter': scanFilter,
},
);
return ScanOutput.fromJson(jsonResponse.body);
}