Reputation: 1765
In dynamoDB I should create some kind of log information, that has a state that user could change. But it is unnecessary extra information. Main question is:
{
id: '123',
log: 'mybestlog',
state: 'PENDING'
}
id
not exists.id
exits.Hope I tell all enough clear.
I tried to do:
const result: PutItemOutput = await this.dynamodbClient.put({
TableName: this.config.tableName,
Item: {
...newItem,
status: statusEnum.PENDING,
creationDate: moment().toISOString(),
},
ConditionExpression: 'attribute_not_exists(id)',
ReturnValues: 'ALL_NEW',
})
.promise()
.catch((error) => {
this.logger.error(`### END-ERROR ${methodDescription} | error: ${error}`, metadata);
throw new InternalServerErrorException(error.stack);
});
But can't found any Items
or flags Exist
in response. I got AWS.DynamoDB.PutItemOutput
:
{
Attributes?,
ConsumedCapacity?,
ItemCollectionMetrics?,
}
Please help me, what the best solution is in my situation.
Upvotes: 0
Views: 126
Reputation: 171
you don't get a response with a flag that an item exits in dynamoDB, the way you're thinking.
When you call put operation with that ConditionExpression. The two major outcomes and those that matter for you are:
You'll need to tailor a response yourself accordingly.
Upvotes: 4