Me trying to apply what I have learned from this book, and also to learn more about "Serverless".
Access Pattern | Index | Key Condition | Filter Condition |
---|---|---|---|
Get Products | |||
by productID | Table | PK = productID | |
by category | GSI1 | GSI1PK = category | |
by category and price | GSI1 | GSI1PK = category, GSI1PK between(price1, price2) | |
Get Product Reviews | |||
by reviewID | Table | PK = productID, SK = reviewID | |
Get Basket Products | |||
by userID | Table | PK = userID | |
Get Users Dashboard | |||
get reviews | Table | GSI1PK = userID | |
get orders | Table | GSI1PK = userID | |
Get Reviews | |||
by productID | Table | PK = productID, SK begins_with("REVIEW#") | |
by userID | GSI1 | GSI1PK = USER, GSI2SK begins_with("REVIEW#") | |
Get Orders | |||
by userID | Table | PK = userID, SK begins_with("ORDER#") | |
Get Orders Details | |||
by orderID | GSI1 | GSI1PK = orderID |
Main Table
Entity | PK | SK |
---|---|---|
Basket | Basket#[CustomerID] | PRODUCT#[Date] |
Product | Product#[ProductID] | METADATA# |
Option | Product#[ProductID] | OPTION#[OptionID] |
Review | Product#[ProductID] | REVIEW#[ReviewID] |
Order | USER#[UserID] | ORDER#[OrderId] |
OrderLineItem | ORDERITEM#[ItemID] | Order#[OrderID] |
Category | N/A | N/A |
GSI1
Entity | GSI1PK | GSI1SK |
---|---|---|
Product | PRODUCT#CATEGORY#[Category] | [Price] |
Review | USER#[UserID] | REVIEW#[Date] |
Order | ORDER#[OrderId] | METADATA# |
OrderLineItem | ORDER#[OrderID] | ORDERITEM#[ItemId] |
- Install docker.
- Run
docker-compose up
at the root of the project, this will run DynamoDB locally. - You can now run
go test ./...
this will run all the tests.
Test Tip
- Download NoSQL Workbench
func TestSomethingInDynamoDB(t *testing.T) {
tdb, _ := NewTestDynamoDB() // creates a table in your DynamoDB instance.
// If you comment out the Close method it will not delete the test database that got created.
// This give you an opportunity to peek into the instance with NoSQL Workbench.
// defer tdb.Close()
}