Amazon DynamoDB MildStack provides DynamoDB emulation with table management, item operations,
queries, scans, secondary indexes, and batch/transaction support.
MildStack's DynamoDB emulation lets you create tables, store items, and perform queries locally. It supports the standard DynamoDB JSON wire protocol, so your existing AWS SDK code works without changes — just update the endpoint URL.
Operation Description CreateTableCreate a new table with key schema and optional indexes DescribeTableGet table details (status, key schema, indexes, item count) ListTablesList all tables DeleteTableDelete a table and all its items
Operation Description PutItemCreate or replace an item GetItemRetrieve a single item by key UpdateItemUpdate specific attributes of an item DeleteItemDelete a single item by key
Operation Description QueryQuery items by partition key with optional sort key conditions ScanScan all items in a table with optional filters
Operation Description BatchGetItemGet multiple items across tables in a single request BatchWriteItemPut or delete multiple items across tables in a single request TransactGetItemsRead multiple items atomically TransactWriteItemsWrite multiple items atomically
Operation Description UpdateTimeToLiveEnable or disable TTL on a table DescribeTimeToLiveGet the current TTL configuration
MildStack supports both types of secondary indexes:
Global Secondary Indexes (GSI) — Query items by any attribute, across all partitions
Local Secondary Indexes (LSI) — Query items by an alternative sort key within a partition
import {
DynamoDBClient,
CreateTableCommand,
PutItemCommand,
QueryCommand,
} from "@aws-sdk/client-dynamodb" ;
const client = new DynamoDBClient ({
region: "us-east-1" ,
endpoint: "http://localhost:4566" ,
credentials: { accessKeyId: "test" , secretAccessKey: "test" },
});
// Create a table
await client. send (
new CreateTableCommand ({
TableName: "Orders" ,
KeySchema: [
{ AttributeName: "customerId" , KeyType: "HASH" },
{ AttributeName: "orderId" , KeyType: "RANGE" },
],
AttributeDefinitions: [
{ AttributeName: "customerId" , AttributeType: "S" },
{ AttributeName: "orderId" , AttributeType: "S" },
],
BillingMode: "PAY_PER_REQUEST" ,
})
);
// Put an item
await client. send (
new PutItemCommand ({
TableName: "Orders" ,
Item: {
customerId: { S: "cust-123" },
orderId: { S: "order-001" },
total: { N: "59.99" },
status: { S: "shipped" },
},
})
);
// Query items for a customer
const result = await client. send (
new QueryCommand ({
TableName: "Orders" ,
KeyConditionExpression: "customerId = :cid" ,
ExpressionAttributeValues: {
":cid" : { S: "cust-123" },
},
})
);
console. log (result.Items);
# Create a table with a GSI
awslocal dynamodb create-table \
--table-name Products \
--attribute-definitions \
AttributeName=id,AttributeType=S \
AttributeName=category,AttributeType=S \
--key-schema AttributeName=id,KeyType=HASH \
--global-secondary-indexes \
'[{
"IndexName": "CategoryIndex",
"KeySchema": [{"AttributeName": "category", "KeyType": "HASH"}],
"Projection": {"ProjectionType": "ALL"}
}]' \
--billing-mode PAY_PER_REQUEST
# Put an item
awslocal dynamodb put-item \
--table-name Products \
--item '{
"id": {"S": "prod-1"},
"category": {"S": "electronics"},
"name": {"S": "Wireless Mouse"},
"price": {"N": "29.99"}
}'
# Query by GSI
awslocal dynamodb query \
--table-name Products \
--index-name CategoryIndex \
--key-condition-expression "category = :cat" \
--expression-attribute-values '{":cat": {"S": "electronics"}}'
# Scan with filter
awslocal dynamodb scan \
--table-name Products \
--filter-expression "price < :maxPrice" \
--expression-attribute-values '{":maxPrice": {"N": "50"}}'
MildStack supports all DynamoDB attribute types:
Type Code Example String S{"S": "hello"}Number N{"N": "42"}Boolean BOOL{"BOOL": true}Null NULL{"NULL": true}Map M{"M": {"key": {"S": "value"}}}List L{"L": [{"S": "a"}, {"N": "1"}]}
All DynamoDB data is stored in a local database on your machine. Tables, items, and index data persist across instance restarts. Deleting an instance removes all its DynamoDB data.