Skip to content

Commit

Permalink
Rename "columns" in db to "keys"
Browse files Browse the repository at this point in the history
"Columns" is misleading because it implies that every field of the table
ought to be specified, which is contrary to how NoSQL databases work.
  • Loading branch information
chennisden committed May 29, 2024
1 parent 7bdfbc0 commit 6fca9af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions store/app/api/crud/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None: #
async def _create_dynamodb_table(
self,
name: str,
columns: list[tuple[str, Literal["S", "N", "B"], Literal["HASH", "RANGE"]]],
keys: list[tuple[str, Literal["S", "N", "B"], Literal["HASH", "RANGE"]]],
deletion_protection: bool = False,
) -> None:
table = await self.db.create_table(
AttributeDefinitions=[{"AttributeName": n, "AttributeType": t} for n, t, _ in columns],
AttributeDefinitions=[{"AttributeName": n, "AttributeType": t} for n, t, _ in keys],
TableName=name,
KeySchema=[{"AttributeName": n, "KeyType": t} for n, _, t in columns],
KeySchema=[{"AttributeName": n, "KeyType": t} for n, _, t in keys],
DeletionProtectionEnabled=deletion_protection,
BillingMode="PAY_PER_REQUEST",
)
Expand Down
6 changes: 3 additions & 3 deletions store/app/api/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ async def create_tables(crud: Crud | None = None) -> None:
await asyncio.gather(
crud._create_dynamodb_table(
name="Users",
columns=[
keys=[
("id", "S", "HASH"),
],
),
crud._create_dynamodb_table(
name="Tokens",
columns=[
keys=[
("id", "S", "HASH"),
],
),
crud._create_dynamodb_table(
name="Robots",
columns=[
keys=[
("id", "S", "HASH"),
]
)
Expand Down

0 comments on commit 6fca9af

Please sign in to comment.