AWS DynamoDB NodeJS 事务 - 尝试使用 Put & Delete 创建 'move' 但 ValidationError
AWS DynamoDB NodeJS Transactions - Trying to create 'move' with Put & Delete but ValidationError
我正在尝试在 DynamoDB 中对一个 table 的数据进行简单的事务处理 'move'(以添加索引)。这是我正在打的电话,因为我正在使用 .then() 来解释它,所以返回了承诺,但是正如你从结果中看到的那样,我回来了 something我的 JSON 有问题。不幸的是,错误消息不是很有帮助。非常感谢任何帮助。
var runner = async (column1Value, column2Value) => {
return await ddb.transactWriteItems({
TransactItems: [
{
Delete: {
TableName: 'TABLE_V2',
Key: {
AuthorName: {
S: column1Value
}
}
}
}
,
{
Put: {
Item: {
'AuthorName': {
S: column1Value
},
'AuthorTitle': {
S: column2Value
}
},
TableName: 'TABLE_V3'
}
}
]
}).promise();
}
当我 运行 我的代码时,我得到以下信息:
at Request.extractError...
message: 'Transaction cancelled, please refer cancellation reasons for specific reasons [ValidationError, None]',
code: 'TransactionCanceledException',
time: 2019-03-31T00:03:05.401Z,
requestId: 'URIARNJDVFHDVLQQNR1JMIJP5NVV4KQNSO5AEMVJF66Q9ASUAAJG',
statusCode: 400,
retryable: false,
retryDelay: 30.057548210067033
我已经阅读了一些网站,但所有网站都提到了 DynamoDB 原生支持事务之前的时间。transactWriteItems()。
例如:
好的,所以,有两个问题(如果它们与本网站无关,请告诉我)。
- 第一列的列名后有一个 space 字符引发了 'Put' 错误:'AuthorName '
- 'Delete' 错误是由于 TABLE_V2 不仅使用主键而且还使用搜索键,因此它的 JSON 需要是:
Delete: {
TableName: 'TABLE_V2',
Key: {
AuthorName: {
S: column1Value
},
AuthorTitle: {
S: column2Value
}
}
}
我正在尝试在 DynamoDB 中对一个 table 的数据进行简单的事务处理 'move'(以添加索引)。这是我正在打的电话,因为我正在使用 .then() 来解释它,所以返回了承诺,但是正如你从结果中看到的那样,我回来了 something我的 JSON 有问题。不幸的是,错误消息不是很有帮助。非常感谢任何帮助。
var runner = async (column1Value, column2Value) => {
return await ddb.transactWriteItems({
TransactItems: [
{
Delete: {
TableName: 'TABLE_V2',
Key: {
AuthorName: {
S: column1Value
}
}
}
}
,
{
Put: {
Item: {
'AuthorName': {
S: column1Value
},
'AuthorTitle': {
S: column2Value
}
},
TableName: 'TABLE_V3'
}
}
]
}).promise();
}
当我 运行 我的代码时,我得到以下信息:
at Request.extractError...
message: 'Transaction cancelled, please refer cancellation reasons for specific reasons [ValidationError, None]',
code: 'TransactionCanceledException',
time: 2019-03-31T00:03:05.401Z,
requestId: 'URIARNJDVFHDVLQQNR1JMIJP5NVV4KQNSO5AEMVJF66Q9ASUAAJG',
statusCode: 400,
retryable: false,
retryDelay: 30.057548210067033
我已经阅读了一些网站,但所有网站都提到了 DynamoDB 原生支持事务之前的时间。transactWriteItems()。
例如:
好的,所以,有两个问题(如果它们与本网站无关,请告诉我)。
- 第一列的列名后有一个 space 字符引发了 'Put' 错误:'AuthorName '
- 'Delete' 错误是由于 TABLE_V2 不仅使用主键而且还使用搜索键,因此它的 JSON 需要是:
Delete: {
TableName: 'TABLE_V2',
Key: {
AuthorName: {
S: column1Value
},
AuthorTitle: {
S: column2Value
}
}
}