Skip to the content.

DynamoTableIndex

Auto-generated documentation for dynamo_query.dynamo_table_index module.

DynamoTableIndex

[find in source code]

class DynamoTableIndex():
    def __init__(
        name: str,
        partition_key_name: str,
        sort_key_name: Optional[str],
        partition_key_type: ScalarAttributeTypeType = 'S',
        sort_key_type: ScalarAttributeTypeType = 'S',
        read_capacity_units: Optional[int] = None,
        write_capacity_units: Optional[int] = None,
        projection: Iterable[str] = tuple(),
    ):

Constructor for DynamoDB global and local secondary index structures.

Arguments

Usage:

table_index = DynamoTableIndex("lsi_my_attr", "my_attr")
table_index.as_dynamodb_dict()
# {
#     "IndexName": "lsi_my_attr",
#     "KeySchema": [
#         {"AttributeName": "pk", "KeyType": "HASH",},
#         {"AttributeName": "my_attr", "KeyType": "RANGE"},
#     ],
#     "Projection": {"ProjectionType": "ALL"},
# }

#### Attributes

- `PRIMARY` - Special name for primary table index: `'primary'`
- `TYPES_MAP` - Map to python types: `{'S': str, 'N': int, 'B': bytes}`

#### See also

- [ScalarAttributeTypeType](/dynamoquery/dynamo_query/dynamo_query_types.html#scalarattributetypetype)

### DynamoTableIndex().as_attribute_definitions

[[find in source code]](https://github.com/altitudenetworks/dynamoquery/blob/master/dynamo_query/dynamo_table_index.py#L151)

```python
def as_attribute_definitions() -> List[AttributeDefinitionTypeDef]:

DynamoTableIndex().as_global_secondary_index

[find in source code]

def as_global_secondary_index() -> GlobalSecondaryIndexTypeDef:

Output a dictionary to use in dynamo_client.create_table method.

Returns

A dict with index data.

See also

DynamoTableIndex().as_key_schema

[find in source code]

def as_key_schema() -> List[KeySchemaElementTypeDef]:

Output a dictionary to use in dynamo_client.create_table method.

Returns

A dict with index data.

DynamoTableIndex().as_local_secondary_index

[find in source code]

def as_local_secondary_index() -> LocalSecondaryIndexTypeDef:

Output a dictionary to use in dynamo_client.create_table method.

Returns

A dict with index data.

See also

DynamoTableIndex().get_query_data

[find in source code]

def get_query_data(
    partition_key: str,
    sort_key: Optional[str],
) -> Dict[(str, str)]:

Get query-ready data with partition_key and sort_key values.

Arguments

Returns

Query-ready data.

DynamoTableIndex().name

[find in source code]

@property
def name() -> Optional[str]:

Get index name to use in queries.