Return the number of elements in a table or a secondary index.
Methods
(inner) count(request) → {Promise}
- Source:
- See:
Return the number of elements in a table or a secondary index. This function
uses Scan
internally and retrieves the returned Count
attribute from its response.
Example
// Returns the total count of items in `SomeTable`
await count({ TableName: 'SomeTable' });
Parameters:
Name | Type | Description |
---|---|---|
request |
Object | Parameters as expected by DynamoDB |
Returns:
A promise that resolves to the total number of elements
- Type
- Promise
(inner) countFor(tableName, requestopt) → {Promise}
- Source:
- See:
Creates a function that returns the number of elements in a table or a secondary index.
This function uses Scan
internally and retrieves the returned Count
attribute from its response.
The last request
argument is optional and is only required if any non mandatory attribute
needs to be included in the request.
You would typically use this function through forTable
.
Examples
// Returns the total count of items in `SomeTable`
await countFor('SomeTable')();
// Exported from `forTable`
const { count } = forTable('SomeTable');
await count();
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
tableName |
String | The name of the table to perform the operation on |
|
request |
Object |
<optional> |
Parameters as expected by DynamoDB |
Returns:
A promise that resolves to the total number of elements on tableName
.
- Type
- Promise