gpt4 book ai didi

amazon-dynamodb - Amazon DynamoDB putItem 返回空值

转载 作者:行者123 更新时间:2023-12-05 01:44:56 26 4
gpt4 key购买 nike

我正在使用 AmazonDynamoDBClient putItem 方法在数据库中插入项目。 putItem 的返回类型是 PutItemResult,但我将其设置为 null。

AmazonDynamoDBClient client = new AmazonDynamoDBClient();
PutItemRequest r = new PutItemRequest();
r.addItemEntry("custId",new Attribute Value("101"));
PutItemResult result = client.putItem(r);
//result is null

项目已成功插入数据库,但为什么结果为空?

最佳答案

请根据您的要求指定RETURN_VALUE。默认为NONE

ReturnValues — (String) Use ReturnValues if you want to get the item attributes as they appeared before they were updated with the PutItem request. For PutItem, the valid values are:

NONE - If ReturnValues is not specified, or if its value is NONE, then nothing is returned. (This setting is the default for ReturnValues.) ALL_OLD - If PutItem overwrote an attribute name-value pair, then the content of the old item is returned. Note: The ReturnValues parameter is used by several DynamoDB operations; however, PutItem does not recognize any values other than NONE or ALL_OLD.

来自 API 文档:-

public PutItemRequest(String tableName,
Map<String,AttributeValue> item,
String returnValues)

Set return values

The ReturnValues parameter is used by several DynamoDB operations; however, PutItem does not recognize any values other than NONE or ALL_OLD.

ALL_NEW、UPDATED_NEW 和 UPDATED_OLD 用于 UpdateItem 操作。

UPDATED_OLD - Returns only the updated attributes, as they appeared before the UpdateItem operation.

ALL_NEW - Returns all of the attributes of the item, as they appear after the UpdateItem operation.

UPDATED_NEW - Returns only the updated attributes, as they appear after the UpdateItem operation.

关于amazon-dynamodb - Amazon DynamoDB putItem 返回空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43997338/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com