Auto populate timestamp in DynamoDB

前端 未结 2 1674
北恋
北恋 2021-01-11 17:16

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.

2条回答
  •  爱一瞬间的悲伤
    2021-01-11 17:59

    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

提交回复
热议问题