Search code examples
node.jsarraysamazon-dynamodbserverlessdata-handling

How to push the dynamo db data object into associative array in nodejs serverless dynamodb


i need the below array format data in nodejs serverless Dynamodb

i need my output like the below json format how to i get it the format

"user": {
 "e8de014a-22c1-12bf-4653-577c8031138":{
   "email": "mailto:[email protected]",
   "method": [
    "email"
   ],
   "name": "Raj",
   "onDemand": "yes",
   "pollSchedule": "None",
   "pollTarget": "Educator",
   "telephone": "12345678",
   "user_id": "413ca05f-ed91-50e7-1974-3e0280ca4a3d"
  },
  "5f4db059-c8a3-e673-iygk-d857425e1077": {
   "created_at": 1674459043374,
   "email": "mailto:[email protected]",
   "method": [
    "email"
   ],{
   "name": "New testing",
   "onDemand": "yes",
   "pollSchedule": "None",
   "pollTarget": "Educator",
   "telephone": "12345678",
   "user_id": "413ca05f-ed91-50e7-2635-3e0280ca4a3d"
  }
 }

Solution

  • Use the DynamoDB Document Client to Put and Get the data as it's native JSON format.

    The DynamoDB document client simplifies working with items by abstracting the notion of attribute values. This abstraction annotates native JavaScript types supplied as input parameters, as well as converts annotated response data to native JavaScript types.