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

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

问题描述

我来自关系数据库背景,我们有办法为行创建和更新填充时间戳.我很难为 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

推荐答案

使用 Annotation 的 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天全站免登陆