DynamoDB的UUID? [英] UUIDs for DynamoDB?

查看:88
本文介绍了DynamoDB的UUID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在向表中添加新项目时,是否有可能使DynamoDB自动生成唯一ID?

Is it possible to get DynamoDB to automatically generate unique IDs when adding new items to a table?

我注意到Java API提到了@DynamoDBAutoGeneratedKey,所以我假设

I noticed the Java API mentions @DynamoDBAutoGeneratedKey so I'm assuming there's a way to get this working with PHP as well.

如果是这样,应用程序代码会生成这些ID还是在DynamoDB上完成?

If so, does the application code generate these IDs or is it done on the DynamoDB side?

推荐答案

很好的问题-虽然从概念上讲是可能的,但目前看来这不是DynamoDB API级别的功能,因此在CreateTable PutItem 是指此类功能。

Good question - while conceptually possible, this seems not currently available as a DynamoDB API level feature, insofar neither CreateTable nor PutItem refer to such a functionality.

您注意到的 @DynamoDBAutoGeneratedKey 表示法是 Java注释,即Java提供的语法糖SDK确实是:

The @DynamoDBAutoGeneratedKey notation you have noticed is a Java annotation, i.e. syntactic sugar offered by the Java SDK indeed:


在Java计算机编程语言中,注释是一种特殊的
形式的语法元数据,可以添加

An annotation, in the Java computer programming language, is a special form of syntactic metadata that can be added to Java source code.

因此 @DynamoDBAutoGeneratedKey Amazon DynamoDB注释作为Java SDK的高级API中 Object Persistence Model 的一部分提供(请参见在Amazon DynamoDB中使用对象持久性模型):

As such @DynamoDBAutoGeneratedKey is one of the Amazon DynamoDB Annotations offered as part of the Object Persistence Model within the Java SDK's high-level API (see Using the Object Persistence Model with Amazon DynamoDB):


标记哈希键或范围键属性为自动生成。保存这些
属性时,
对象持久性模型将生成一个随机UUID。只能将String属性标记为自动生成的
键。

Marks a hash key or range key property as being auto-generated. The Object Persistence Model will generate a random UUID when saving these attributes. Only String properties can be marked as auto-generated keys.

这篇关于DynamoDB的UUID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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