Return the number of elements in a table or a secondary index.
- Description:
Return the number of elements in a table or a secondary index.
- Source:
- See:
Methods
(inner) count(request) → {Promise}
- Description:
Return the number of elements in a table or a secondary index. This function uses
Scaninternally and retrieves the returnedCountattribute from its response.
- Source:
- See:
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}
- Description:
Creates a function that returns the number of elements in a table or a secondary index. This function uses
Scaninternally and retrieves the returnedCountattribute from its response. The lastrequestargument is optional and is only required if any non mandatory attribute needs to be included in the request. You would typically use this function throughforTable.
- Source:
- See:
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