I come from Relational Database background and we have a way to populate timestamp for row creation and update. I am having difficulty finding similar feature for DynamoDB.
Java Solution using Annotation (Data modelling package)
You can use the DynamoDBAutoGeneratedTimestamp
annotation.
@DynamoDBAutoGeneratedTimestamp(strategy=DynamoDBAutoGenerateStrategy.CREATE)
public Date getCreatedDate() { return createdDate; }
public void setCreatedDate(Date createdDate) { this.createdDate = createdDate; }
@DynamoDBAutoGeneratedTimestamp(strategy=DynamoDBAutoGenerateStrategy.ALWAYS)
public Date getLastUpdatedDate() { return lastUpdatedDate; }
public void setLastUpdatedDate(Date lastUpdatedDate) { this.lastUpdatedDate = lastUpdatedDate; }
DynamoDBAutoGeneratedTimestamp
There is no such functionality like
DEFAULT CURRENT TIMESTAMP
or UPDATE CURRENT_TIMESTAMP
.
You will have to set the date by yourself.
However if you want to keep track of changes on updates then you can use something like atomic counters.
Thus on every update your will increment the counter value.