DynamoDB 的 UUID? [英] UUIDs for DynamoDB?

查看:27
本文介绍了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,所以我假设有一种方法可以让它与 PHP 一起使用.

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 级别的功能使用,因此 CreateTablePutItem 参考这样的功能.

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 计算机编程语言中,是一种特殊的可以添加到 Java 源代码中的语法元数据形式.

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

因此 @DynamoDBAutoGeneratedKeyAmazon DynamoDB Annotations 之一,作为 Java SDK 高级中的对象持久性模型 的一部分提供API(请参阅将对象持久性模型与 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属性.只有字符串属性可以标记为自动生成键.

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天全站免登陆