2016-09-27 24 views

回答

1

幾件事情:

  • 查詢必須是針對表/索引的主鍵(所以沒有在GSI加盟)
  • 據我所知,你不能ConditionalExpressions添加到batchWriteItem。
  • batchWriteItem無法更新。 (see first note here

我會做這樣的事情:

// 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()))); 
+0

我認爲,回答我的問題。這是我正在使用的Java,而不是Javascript,但我明白了它的要點。 – RTF

相關問題