2016-09-08 3 views
0

Ich versuche, ein Element in DynamoDB Tabelle zu aktualisieren:DynamoDB Update Artikel Multi Aktion

var params = { 
     TableName: 'User', 
    Key: { 
     id: 'b6cc8100-74e4-11e6-8e52-bbcb90cbdd26', 
    }, 
    UpdateExpression: 'ADD past_visits :inc, past_chats :inc', 
    ExpressionAttributeValues: { 
     ':inc': 1 
    }, 
     ReturnValues: 'ALL_NEW' 
    }; 
    docClient.update(params, function(err, data) { 
     if (err) ppJson(err); // an error occurred 
     else ppJson(data); // successful response 
    });   

Es funktioniert. Aber ich will noch mehr Wert setzen (reset_time =: Wert ') wie folgt aus:

var params = { 
     TableName: 'User', 
    Key: { 
     id: 'b6cc8100-74e4-11e6-8e52-bbcb90cbdd26', 
    }, 
    UpdateExpression: 'ADD past_visits :inc, past_chats :inc, SET reset_time = :value', 
    ExpressionAttributeValues: { 
     ':inc': 1, 
     ':value': 0 
    }, 
     ReturnValues: 'ALL_NEW' 
    }; 
    docClient.update(params, function(err, data) { 
     if (err) ppJson(err); // an error occurred 
     else ppJson(data); // successful response 
    }); 

Kann Unterstützung Multi Aktion in einer Abfrage DynamoDB?

+0

Darf ich um die Antwort bitten, wenn es nützlich ist? Vielen Dank! – notionquest

Antwort

7

Bitte ändern Sie den Update-Ausdruck wie unten erwähnt. Es sollte funktionieren.

Es gibt kein Komma zwischen dem zweiten ": inc" und SET.

UpdateExpression : "ADD past_visits :inc, past_chats :inc SET reset_time = :value", 
+0

Sorry für späte Antwort, es funktioniert :) –