DynamoDB自动增加ID&服务器时间(iOS SDK) [英] DynamoDB auto incremented ID & server time (iOS SDK)
问题描述
DynammoDB中是否有一个选项可以将自动递增的ID存储为表中的主键?我还需要将服务器时间存储在表中作为创建时字段(例如,用户创建时)。但我没有找到任何方法从DynamoDB或任何其他AWS服务获得服务器时间。
Is there an option in DynammoDB to store auto incremented ID as primary key in tables? I also need to store the server time in tables as the "created at" fields (eg., user create at). But I don't find any way to get server time from DynamoDB or any other AWS services.
你们可以帮助我吗,
- 在DyanmoDB表中使用自动递增的ID
- 在表中为创建时字段存储服务器时间。
谢谢。
推荐答案
实际上,有DynamoDB中很少有功能,这正是它的主要优势。简单。
Actually, there are very few features in DynamoDB and this is precisely its main strength. Simplicity.
- 无法自动生成ID或UUID。
- 没有办法自动生成日期
对于日期问题,应该很容易在客户端生成它。我建议您使用ISO 8601日期格式吗?它既是程序员又是计算机友好的。
For the "date" problem, it should be easy to generate it on the client side. May I suggest you to use the ISO 8601 date format ? It's both programmer and computer friendly.
大多数情况下,有一种比使用物品的自动ID更好的方法。这通常是SQL或MongoDB世界的坏习惯。例如,电子邮件或登录将为用户提供完美的ID。但我知道ID可能有用的具体情况。
Most of the time, there is a better way than using automatic IDs for Items. This is often a bad habit taken from the SQL or MongoDB world. For instance, an e-mail or a login will make a perfect ID for a user. But I know there are specific cases where IDs might be useful.
在这些情况下,您需要构建自己的系统。在此 SO回答和本文来自DynamoDB-Mapper文档,我解释了怎么做它。我希望它有帮助
In these cases, you need to build your own system. In this SO answer and this article from DynamoDB-Mapper documentation, I explain how to do it. I hope it helps
这篇关于DynamoDB自动增加ID&服务器时间(iOS SDK)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!