PutItem
Creates a new item or replaces an existing item with the same primary key. Use ConditionExpression to prevent accidental overwrites.
Syntax
dynamodb
await docClient.send(new PutCommand({ TableName, Item, ConditionExpression }))Example
dynamodb
await docClient.send(new PutCommand({
TableName: 'Users',
Item: { PK: 'USER#alice', SK: 'PROFILE', name: 'Alice' },
ConditionExpression: 'attribute_not_exists(PK)',
}));