在DynamoDB中自动填充时间戳 [英] Auto populate timestamp in DynamoDB

查看:175
本文介绍了在DynamoDB中自动填充时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我来自Relational Database的背景,我们有一种方法来填充用于行创建和更新的时间戳。
我很难找到DynamoDB的类似功能。

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.

我检查了DynamoDB,以检查它们是否支持为dynamoDB中的每个条目自动填充日期时间戳。我看到可以创建随机ID,但这不是我所需要的。

I checked DynamoDB to check if they support autopopulate the date timestamp for every entry in dynamoDB. I see it is possible to create random ID but that is not what I need.

我的用例是在向DynamoDB表添加任何条目时自动添加一个时间戳记条目。感谢任何指针。谢谢

My usecase is to add a timestamp entry automatically when I add any entry to DynamoDB Table. Appreciate any pointers. Thanks

推荐答案

使用注释的Java解决方案(数据建模包)

您可以使用 DynamoDBAutoGeneratedTimestamp 批注。

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

这篇关于在DynamoDB中自动填充时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆