Replies: 1 comment 3 replies
-
|
Hi @chemzo ElectroDB is a library, similar to an ORM, that helps you to model your data in terms of entities (or objects) and query these entities efficiently. In contrast to classical SQL libraries, ElectroDB works with a single table (even if you could use multiple tables if you want to) and it uses some clever design around composite keys to distinguish different entities from each other. Here is a typical table definition in CloudFormation JSON with {
"EntityTable": {
"Type": "AWS::DynamoDB::Table",
"Properties": {
"TableName": "nebula-api-dev",
"BillingMode": "PAY_PER_REQUEST",
"KeySchema": [
{
"AttributeName": "pk",
"KeyType": "HASH"
},
{
"AttributeName": "sk",
"KeyType": "RANGE"
}
],
"AttributeDefinitions": [
{
"AttributeName": "pk",
"AttributeType": "S"
},
{
"AttributeName": "sk",
"AttributeType": "S"
},
{
"AttributeName": "gsi1pk",
"AttributeType": "S"
},
{
"AttributeName": "gsi1sk",
"AttributeType": "S"
},
{
"AttributeName": "gsi2pk",
"AttributeType": "S"
},
{
"AttributeName": "gsi2sk",
"AttributeType": "S"
},
{
"AttributeName": "gsi3pk",
"AttributeType": "S"
},
{
"AttributeName": "gsi3sk",
"AttributeType": "S"
}
],
"GlobalSecondaryIndexes": [
{
"IndexName": "gsi1pk-gsi1sk-index",
"KeySchema": [
{
"AttributeName": "gsi1pk",
"KeyType": "HASH"
},
{
"AttributeName": "gsi1sk",
"KeyType": "RANGE"
}
],
"Projection": {
"ProjectionType": "ALL"
}
},
{
"IndexName": "gsi2pk-gsi2sk-index",
"KeySchema": [
{
"AttributeName": "gsi2pk",
"KeyType": "HASH"
},
{
"AttributeName": "gsi2sk",
"KeyType": "RANGE"
}
],
"Projection": {
"ProjectionType": "ALL"
}
},
{
"IndexName": "gsi3pk-gsi3sk-index",
"KeySchema": [
{
"AttributeName": "gsi3pk",
"KeyType": "HASH"
},
{
"AttributeName": "gsi3sk",
"KeyType": "RANGE"
}
],
"Projection": {
"ProjectionType": "ALL"
}
}
]
}
},
}When you compare it to the Human Resources example, you'll see that every index (the example has 5) maps to a partition and sort key. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I've been going through the documentation and it's not clear to me how the table definition in the first example ( https://electrodb.dev/en/examples/human-resources ) maps to the entities?
Is that just a base table definition that later needs to be manually updated?
Is there any tool to get a dynamodb table definition based on the Entities defined in a service?
Thank you!!
Beta Was this translation helpful? Give feedback.
All reactions