【发布时间】:2021-05-15 05:45:45
【问题描述】:
这是我第一次使用 DynamoDB,并在我的系统中为用户帐户创建了一个表。
表定义如下:
{
"Table": {
"AttributeDefinitions": [
{
"AttributeName": "AccountId",
"AttributeType": "B"
},
{
"AttributeName": "Email",
"AttributeType": "S"
}
],
"KeySchema": [
{
"AttributeName": "AccountId",
"KeyType": "HASH"
}
],
"GlobalSecondaryIndexes": [
{
"IndexName": "EmailAddress",
"KeySchema": [
{
"AttributeName": "Email",
"KeyType": "HASH"
}
],
"Projection": {
"ProjectionType": "ALL"
},
"IndexStatus": "ACTIVE"
}
]
}
}
为简洁起见,省略了一些字段。
我正在使用 Rusoto DynamoDB 客户端,这就是 PutItem 调用的样子:
dynamodb_client.put_item(PutItemInput{
item: account_doc.as_hashmap(),
table_name: accounts_datastore_name,
condition_expression: Some("attribute_not_exists(Email) and attribute_not_exists(AccountId)".to_string()),
..PutItemInput::default()
});
据我了解,这应该具有以下行为:如果有文档包含 Email 和我在新文档中提供的值或 AccountId 的值我是在新文档中提供。
我已经能够多次提交同一个文档,而服务没有任何错误。文件都在表格中。
知道为什么这个条件表达式允许文档通过吗?
【问题讨论】:
标签: amazon-dynamodb