0
將全局二級索引的值用作條件表達式時,是否可以批量寫入DynamoDB(在文檔API中使用Java SDK v1.11.1)?是否可以使用AWS DynamoDB在GSI上使用條件表達式進行批處理寫入?
例如,我想發出一個批量更新請求,用於更新GSI MyIndex
等於某個值的任何項目的屬性A,B和C.
這是可能的,還是我必須對GSI執行查詢,並使用生成的主鍵進行批量寫入?
將全局二級索引的值用作條件表達式時,是否可以批量寫入DynamoDB(在文檔API中使用Java SDK v1.11.1)?是否可以使用AWS DynamoDB在GSI上使用條件表達式進行批處理寫入?
例如,我想發出一個批量更新請求,用於更新GSI MyIndex
等於某個值的任何項目的屬性A,B和C.
這是可能的,還是我必須對GSI執行查詢,並使用生成的主鍵進行批量寫入?
幾件事情:
我會做這樣的事情:
// Get keys from GSI
dynamodb.query({
IndexName: 'index',
TableName: 'table',
KeyConditionExpression: 'some expression',
}, (error, rows) =>
// Spin up a bunch of update requests
Promise.all(rows.Items.map((row) => dynamodb.update({
ExpressionAttributeValues: {
':aVal': 'new value for a',
':bVal': 'etc',
':cVal': 'etc',
},
IndexName: 'index',
Key: {
primaryKey: row.primaryKey,
},
KeyConditionExpression: 'primaryKey = :primKey',
UpdateExpression: 'set a = :aVal, b = :bVal, c = :cVal',
}).promise())));
我認爲,回答我的問題。這是我正在使用的Java,而不是Javascript,但我明白了它的要點。 – RTF