默认情况下,即使对不存在的项目执行操作,boto3 中的delete_item 也不会返回错误。
id = '123'
timenow = '1589046426'
dynamodb = boto3.resource('dynamodb')
boto3_table = dynamodb.Table(MY_TABLE)
response = boto3_table.delete_item(Key={"ID": id, "TIMENOW": timenow})
Run Code Online (Sandbox Code Playgroud)
如何更改上面的代码以强制 delete_item 在项目不存在时返回错误?
我有一个简单的逻辑,我想INSERT使用 记录在表中AWS.DynamoDB.DocumentClient。下面是我正在使用的代码。在这里,我注意到.put正在更新记录,但不知道为什么。
在检查 CW 中的日志时,我没有看到任何错误,所以不确定我在这里错过了什么。
代码:
async addEvent(incomingModel: MyModel): Promise <MyModel> {
const dynamoModel: MyModel = {
fieldOne: incomingModel.fieldOne,
fieldTwo: incomingModel.fieldTwo,
"One#two#three": `${incomingModel.one}#${incomingModel.two}#${incomingModel.three}`,
fieldThree: incomingModel.fieldThree,
fieldFour: incomingModel.fieldFour,
};
var params = {
TableName: 'Table',
Item: dynamoModel,
};
return this.documentClient
.put(params)
.then((data) => {
this.logger.debug(
"Response received from Dynamo after adding an incomingModel",
data,
this.constructor.name,
);
return data as MyModel;
})
.catch((error) => {
const errorMessage = JSON.stringify(error);
this.logger.error(
`Error creating incomingModel with body of …Run Code Online (Sandbox Code Playgroud) amazon-web-services node.js amazon-dynamodb typescript documentclient
我有一个生成的索引页面,我可以看到如何在目录的类别.json中自定义页面标题和描述,但是有没有办法自定义同一目录中的文件生成的项目?例如:
我希望能够为每个文件提供一个图标,并且与从这些文件中提取的文本不同的文本第一段似乎是默认的。我想要的也许看起来像这个页面,但图标和文本需要链接到教程页面。
我尝试过使用 DocCardList、添加描述、添加项目(失败)以及更改我的每个教程文件,但到目前为止,还没有任何进展。
我有一个只有哈希键的表,我想使用 terraform 添加新的范围键和 GSI,而不影响表中的数据或破坏它。
我知道它有 Prevent_destroy = true 。我想更新表而不删除或破坏旧数据。
旧的:
resource "aws_dynamodb_table" "table" {
name = "table_example"
hash_key = "hash"
attribute {
name = "hash"
type = "S"
}
lifecycle {
prevent_destroy = true
}
}
Run Code Online (Sandbox Code Playgroud)
更新后:
resource "aws_dynamodb_table" "table" {
name = "table_example"
hash_key = "hash"
range_key = "range"
attribute {
name = "hash"
type = "S"
}
attribute {
name = "range"
type = "S"
}
global_secondary_index {
name = "gsi-example"
hash_key = "range"
projection_type = "ALL"
} …Run Code Online (Sandbox Code Playgroud) 我想得到一些数字来证明我的阅读,与关系数据库(MySQL、PostgreSQL、Aurora)相比,DynamoDB 键值存储具有更好的读取性能。所以我决定比较 DynamoDB 和 AWS-Aurora 的读取延迟(这是 AWS 网站的 a/c - “比标准 MySQL 数据库快五倍,比标准 PostgreSQL 数据库快三倍”)
步骤 1:在 Aurora 中使用以下架构创建一个表,并向该表添加 102 万条记录。
Table gift_log (
gift_uuid BINARY(16) NOT NULL,
user_uuid BINARY(16) NOT NULL,
parent_uuid BINARY(16),
operation_time TIMESTAMP,
operation VARCHAR(20) NOT NULL,
gift_type VARCHAR(20) NOT NULL,
parent_type VARCHAR(20),
relation_type VARCHAR(20),
PRIMARY KEY (gift_uuid)
);
Run Code Online (Sandbox Code Playgroud)
使用使用 MySQL 驱动程序的 Golang 客户端数据库/sql 包来查询表。
步骤2;创建了具有以下属性的 DynamoDB 表。向表中添加了 100 万个项目。没有使用任何排序键。所有查询都使用分区键。
Table: GiftLog {
gift_uuid Binary (Partition Key)
user_uuid Binary
operation_time Number,
operation String,
gift_type String, …Run Code Online (Sandbox Code Playgroud) aws-sdk-go ×1
boto3 ×1
docusaurus ×1
go ×1
java ×1
latency ×1
node.js ×1
python ×1
python-3.x ×1
terraform ×1
typescript ×1