How to return the inserted item in dynamoDB
The link you posted is, sadly, the only real answer at this time (API Version 2012-08-10). PutItem
may return items just before they were updated or none at all.
The
ReturnValues
parameter is used by several DynamoDB operations; however,PutItem
does not recognize any values other thanNONE
orALL_OLD
.
In short, the only reliable way to retrieve your inserted object is to GetItem
, just as you surmised.
Just pass the params.Item
in the callback :
dynamo.put(params, (err, data) => {
if (err) {
cb(err);
}
cb(null, params.Item);
});
Pass the err
in the callback too ;)