go-aws-dynamo-with-docker

module
v0.0.0-...-e1a3ad1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2024 License: MIT

README

Go AWS Dynamo with Docker Compose

This repository is a simple example project using DynamoDB with the Go AWS SDK V2 and Docker Compose.

Prerequisites

  • Docker and Docker Compose
  • Go

Steps to Execute

  1. Install dependencies: go get ./...
  2. Run docker-compose up to start the DynamoDB container.
  3. Run go run ./cmd/main.go to execute the Go application.
To stop and remove Docker containers

docker-compose down

Explanation

The setup involves the creation of the database structure in the SetupDatabase function. It checks if the MainSingleTable exists; if not, it creates the table. The table structure consists of a 'pk' and an 'sk' following the SingleTable Desing, with the example entity User having the key definition:

  • pk: USER#username
  • sk: USER#username

After table is created, three users are inserted using 'PutItem'. Finally, the user with the username 'seconduser' is retrieved using 'GetItem'.

How to Check the Data

  • You can install NoSQL Workbench for DynamoDB for a comprehensive view.
  • The Docker Compose runs a Node image with DynamoDB Admin GUI installed. Access it at 'localhost:8001'.

References

Directories

Path Synopsis
internal
dao

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL