Reference

DynamoDB-compatible syntax reference

The DynamoDB-compatible endpoint accepts AWS JSON protocol requests. In the local preview harness, enable it with MTS_LOCAL_DDB_BASE_PORT.

export MTS_LOCAL_CLUSTER_NAME=preview-ddb
export MTS_LOCAL_LEASE_BACKEND=file
export MTS_LOCAL_DDB_BASE_PORT=8000
bash scripts/local-cluster.sh start

Use endpoint URL http://127.0.0.1:8000, region us-east-1, and any non-empty local credentials on the file-backed dev profile.

AWS JSON protocol shape

curl -X POST "http://127.0.0.1:8000/" \
  -H "Content-Type: application/x-amz-json-1.0" \
  -H "X-Amz-Target: DynamoDB_20120810.Query" \
  -d '{
    "TableName": "Docs",
    "KeyConditionExpression": "tenant = :tenant and begins_with(id, :prefix)",
    "ExpressionAttributeValues": {
      ":tenant": {"S": "tenant-alpha"},
      ":prefix": {"S": "doc-"}
    },
    "Limit": 25
  }'

Item operations

{
  "TableName": "Docs",
  "Item": {
    "tenant": {"S": "tenant-alpha"},
    "id": {"S": "doc-1"},
    "title": {"S": "Refund policy"}
  },
  "ReturnConsumedCapacity": "TOTAL"
}
{
  "TableName": "Docs",
  "Key": {
    "tenant": {"S": "tenant-alpha"},
    "id": {"S": "doc-1"}
  },
  "ProjectionExpression": "tenant, id, title",
  "ConsistentRead": true
}
{
  "TableName": "Docs",
  "Key": {
    "tenant": {"S": "tenant-alpha"},
    "id": {"S": "doc-1"}
  },
  "UpdateExpression": "SET title = :title",
  "ExpressionAttributeValues": {
    ":title": {"S": "Updated refund policy"}
  },
  "ReturnValues": "ALL_NEW"
}

Query

Query requires equality on the table or index hash key. The optional sort-key predicate may be equality, comparison, BETWEEN, or begins_with for string/binary sort keys.

{
  "TableName": "Docs",
  "IndexName": "tenant_category_idx",
  "KeyConditionExpression": "tenant = :tenant AND category = :category",
  "FilterExpression": "status = :status",
  "ProjectionExpression": "tenant, id, title",
  "ExpressionAttributeValues": {
    ":tenant": {"S": "tenant-alpha"},
    ":category": {"S": "returns"},
    ":status": {"S": "open"}
  },
  "ScanIndexForward": false,
  "Limit": 50,
  "ReturnConsumedCapacity": "INDEXES"
}

Supported key-condition shapes:

Shape Example
Hash-key equalitytenant = :tenant
Sort-key equalitytenant = :tenant AND id = :id
Sort-key comparisontenant = :tenant AND created_at >= :start
Sort-key betweentenant = :tenant AND created_at BETWEEN :start AND :end
Sort-key prefixtenant = :tenant AND begins_with(id, :prefix)

Scan

Scan is present for compatibility but should not be treated as a safe serving-query substitute. Prefer Query or an MTS access path.

{
  "TableName": "Docs",
  "FilterExpression": "category = :category",
  "ExpressionAttributeValues": {
    ":category": {"S": "returns"}
  },
  "Limit": 25
}

Batch and transaction operations

{
  "RequestItems": {
    "Docs": {
      "Keys": [
        {
          "tenant": {"S": "tenant-alpha"},
          "id": {"S": "doc-1"}
        }
      ],
      "ProjectionExpression": "tenant, id, title"
    }
  },
  "ReturnConsumedCapacity": "TOTAL"
}
{
  "TransactItems": [
    {
      "Put": {
        "TableName": "Docs",
        "Item": {
          "tenant": {"S": "tenant-alpha"},
          "id": {"S": "doc-2"},
          "title": {"S": "Transactional write"}
        }
      }
    },
    {
      "Update": {
        "TableName": "Docs",
        "Key": {
          "tenant": {"S": "tenant-alpha"},
          "id": {"S": "doc-1"}
        },
        "UpdateExpression": "SET status = :status",
        "ExpressionAttributeValues": {
          ":status": {"S": "review"}
        }
      }
    }
  ]
}

DynamoDB operation inventory

Backup, import, and export

CreateBackupDeleteBackupDescribeBackupDescribeExportDescribeImportExportTableToPointInTimeImportTableListBackupsListImportsRestoreTableToPointInTime

Batch

BatchGetItemBatchWriteItem

Global tables

CreateGlobalTableDescribeGlobalTableListGlobalTablesUpdateGlobalTable

Items and reads

DeleteItemGetItemPutItemQueryScanUpdateItem

Streams

DescribeStreamGetRecordsGetShardIteratorListStreams

Table administration

CreateTableDeleteTableDescribeContinuousBackupsDescribeTableDescribeTimeToLiveListTablesUpdateContinuousBackupsUpdateTableUpdateTimeToLive

Transactions

TransactGetItemsTransactWriteItems
Show flat operation table
OperationCategory
BatchGetItemBatch
BatchWriteItemBatch
CreateBackupBackup, import, and export
CreateGlobalTableGlobal tables
CreateTableTable administration
DeleteBackupBackup, import, and export
DeleteItemItems and reads
DeleteTableTable administration
DescribeBackupBackup, import, and export
DescribeContinuousBackupsTable administration
DescribeExportBackup, import, and export
DescribeGlobalTableGlobal tables
DescribeImportBackup, import, and export
DescribeStreamStreams
DescribeTableTable administration
DescribeTimeToLiveTable administration
ExportTableToPointInTimeBackup, import, and export
GetItemItems and reads
GetRecordsStreams
GetShardIteratorStreams
ImportTableBackup, import, and export
ListBackupsBackup, import, and export
ListGlobalTablesGlobal tables
ListImportsBackup, import, and export
ListStreamsStreams
ListTablesTable administration
PutItemItems and reads
QueryItems and reads
RestoreTableToPointInTimeBackup, import, and export
ScanItems and reads
TransactGetItemsTransactions
TransactWriteItemsTransactions
UpdateContinuousBackupsTable administration
UpdateGlobalTableGlobal tables
UpdateItemItems and reads
UpdateTableTable administration
UpdateTimeToLiveTable administration

DynamoDB Query key-condition shapes

  • pk = :pk
  • pk = :pk AND sk = :sk
  • pk = :pk AND sk < :sk
  • pk = :pk AND sk <= :sk
  • pk = :pk AND sk > :sk
  • pk = :pk AND sk >= :sk
  • pk = :pk AND sk BETWEEN :lo AND :hi
  • pk = :pk AND begins_with(sk, :prefix)