使用 DynamoDB 和 docClient,使用 transactWrite 时是否可以获取 return 值?

With DynamoDB and docClient, Is it possible to get return values when using transactWrite?

假设我正在进行更新和删除:

const transactionParams = {
    ReturnConsumedCapacity: "INDEXES",
    TransactItems: [
      {
        Delete: {
          TableName: reactionTableName,
          Key: {
            "SOME_PK_",
            "SOME_SK_",
          },
          ReturnValues: 'ALL_OLD',
        },
      },
      {
        Update: {
          TableName: reviewTableName,
          Key: { PK: "SOME_PK", SK: "SOME_SK" },
          ReturnValues: 'ALL_OLD',
        },
      },
    ],
  };

  try {
    const result = await docClient.transactWrite(transactionParams).promise();
  } catch (error) {
    context.done(error, null);
  }

尽管我将 ReturnValues 用作 "ALL_OLD",但我似乎无法访问它。这可以用 transactWrite 实现吗,还是我需要读完之后再读一遍?

您在回复中查看了 ItemCollectionMetrics 了吗?文档建议它是 table 名称的映射 -> 受查询影响的项目

https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TransactWriteItems.html#API_TransactWriteItems_ResponseElements

await docClient.transactWrite(transactWriteItemsQueryParam, (err, data) => {
        if (err) {
          console.error('Transaction Failed. Error JSON:', JSON.stringify(err, null, 2));
          reject(err);
        } else {
          console.log('Transaction succeeded:', JSON.stringify(data, null, 2));
            //data[0].Items -is result of delete query
            //data[1].Items -is result of update query
          resolve(data);
        }
      });