問題描述
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 answer 和 這篇文章來自 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)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!