DynamoDB
DynamoDB is a fully managed NoSQL database service designed for high performance and scalability.
It is basically a key-value store, but it also supports document-like data structures.
Create a Table
aws dynamodb create-table --table-name users \
--attribute-definitions AttributeName=id,AttributeType=S \
--key-schema AttributeName=id,KeyType=HASH \
--billing-mode PAY_PER_REQUEST
Using SDK
bun add @aws-sdk/client-dynamodb
Here's an example using the SDK to insert and retrieve an item:
import {
DynamoDBClient,
PutItemCommand,
GetItemCommand
} from "@aws-sdk/client-dynamodb"
const client = new DynamoDBClient({})
await client.send(new PutItemCommand({
TableName: 'users',
Item: {
"id": {S: "1"},
"name": { S: "Alice" },
"age": { N: "7" }
}
}))
const data = await client.send(new GetItemCommand({
TableName: 'users',
Key: {
"id": { S: "1" }
}
}))
console.log(data)
The official SDK looks a bit primitive, there are third party libraries like dynamoose, which provides a better developer experience.