向DynamoDB putItem方法提供对象

时间:2019-02-05 13:17:49

标签: object amazon-dynamodb

我有一个多步骤流程,
-从DynamoDB派生对象数组
-操作某些对象的属性值
-将这些对象写回到DynamoDB

当我使用putItem方法时,我想知道在将对象发送到DynamoDB时是否总是需要放置对象的每个属性。还是可以将整个对象作为一个“项目” 发送?

//++++++++++++++++++++++++++
//1) The data-Object I retrieve from Dynamodyb:

data = { Item: 
             { score: 90,
               gtin_RefBook: 'a',
               directConnection: true,
               gtin_RecBook: 'u' 
             }
       }
//++++++++++++++++++++++++++
// 2) The manipulation I perform on the object:
     data.Item.score = 99;

//++++++++++++++++++++++++++
// 3) Current code to write the information back to DynamoDB (as part of the params to be passed to putItem)

Item: {
     "gtin_RefBook": gtinRefBook,
     "gtin_RecBook": gtinRecBook,
     "score": 90,
     "directConnection": true
}

//##########################################################################
// **What I would like to do instead:**
Item: {data}

// so that I can just use the updated data-Object. Is there a possibility to do this?




0 个答案:

没有答案