我正在开发一个将使用DynamoDB的项目,我对如何更新具有包含一系列项目的属性的文档感到困惑。
我希望使用这个NPM模块https://www.npmjs.org/package/dynamodb-model
示例模式
# User Schema
{
"identifier": "String",
"email": "String",
"referral_token": "String",
"campaign_id": "Number",
"first_name": "String"
"last_name": "String",
"gender": "String",
"birth_date": "String",
"username": "String",
"mobile_number": "String",
"postal_code_text": "String",
"classification": "String",
"delivery_email": "Boolean",
"delivery_sms": "Boolean",
"authentications": [{Authentication Schema}]
}
# Authentication Schema
{
"provider": "String",
"uid": "String",
"oauth_token": "String",
"oauth_token_secret": "String",
"nickname": "String"
}
答案 0 :(得分:0)
正如kurtzbot指出的那样,你可以将它们存储为数组。更好的是,您可以使用新的JSON文档模型。它会为您处理数组序列化/反序列化。 http://aws.amazon.com/blogs/aws/dynamodb-update-json-and-more/
另一方面,如果一个用户可以有很多"身份验证",我建议设计这样的架构以避免热点问题:
User table: just like the tables you already have, without authentications fields
Auth table: same table you already have
user-auth table: User.identifier as hashkey, Authentication.uid as range key.
使用此架构,为用户插入新的身份验证不会需要读取任何现有的用户身份验证对。