The short answer is you cannot get the service side to concatenate the values for you. You must do it from the client side, which in your case will mean you need to read the item first, then update it.
However it seems like you are wanting to make your tables sortkey a concatenation of the other two values. In this case, the item would not already exist in the table, as you are not able to change the sortkey of an item. So lets look at this as if you were adding data for the first time.
const AWS = require('aws-sdk')
const ddb = new AWS.DynamoDB.DocumentClient({ region: 'eu-west-1' });
const email = "[email protected]"
const location = "sales"
const params = {
TableName: 'testTable',
Item: {
email: email,
sortKey: `${email}#${location}`,
location: location,
}
}
ddb.put(params)
.promise()
.then(res => console.log(res))
.catch(err => {
console.log("ERROR")
console.log(err.code, err.message);
})
Results:
