@indexes
Defines Global Secondary Indexes for your project's DynamoDB tables. @indexes
should only ever be paired with @tables
.
Recommended
DynamoDB is a powerful database, though different from both SQL and NoSQL databases. It is highly recommended to dig into Amazon's resources to familiarize yourself with it:
- DynamoDB Core Components (start here!)
- Global Secondary Indexes in DynamoDB
- Amazon's full DynamoDB documentation
Syntax
@indexes
is a feature subset of@tables
; as such, the names of your declared indexes must match those of your@tables
- Otherwise, the basic syntax for defining
@indexes
is the same as@tables
:- Partition key, defined by a
*
, is required - Sort key, defined by
**
, is optional - Currently only
*String
,**String
,*Number
and**Number
are supported
- Partition key, defined by a
Example
The following app.arc
file defines a DynamoDB table with two Global Secondary Indexes:
arc
@app
testapp
@tables
accounts
accountID *String
@indexes
accounts
email *String
accounts
created *String
json
{
"app": "testapp",
"tables": [
{ "accounts": { "accountID": "*String" } }
],
"indexes": [
{ "accounts": { "email": "*String" } },
{ "accounts": { "created": "*String" } }
]
}
toml
app="testapp"
[[tables]]
[tables.accounts]
accountID="*String"
indexes = [
{ "accounts" = { "email" = "*String" } },
{ "accounts" = { "created" = "*String" } }
]
yaml
---
app: testapp
tables:
- accounts:
accountID: "*String"
indexes:
- accounts:
- email: "*String"
- accounts:
- created: "*String"