updating a JSON array in AWS dynamoDB

后端 未结 3 1195
你的背包
你的背包 2020-12-11 20:19

My document looks like this:

{
  \"data\": {
      \"eventId\": \"20161029125458-df-d\",
      \"name\": \"first\",
      \"purpose\": \"test\",
      \"loca         


        
3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-11 21:05

    I could not find any answer to query and update the JSON-array. I think this may be AWS profitable motive to not allow those features. If you need to query on a particular ID other than primary key, you need to make a secondary index which is cost effective. This secondary index cost is additional to the dyn amoDB table cost.

    Since, I did not want to pay extra bucks on secondary index, I changed my dynamoDB schema to the following:

    {
      "data": {
          "eventId": "20161029125458-df-d",
          "name": "first",
          "purpose": "test",
          "location": "yokohama",
          "dateArray": [],
          "attendees": {
            "2016102973634-df": {
              "attendeeId": "2016102973634-df",
              "attendeeName": "lakshman",
              "personalizedDateSelection": {}
            },
            "2016102973777-df": {
              "attendeeId": "2016102973777-df",
              "attendeeName": "ffff",
              "personalizedDateSelection": {}
            }
          }
        }
    }
    

    Changing attendees from [] to {}. This allows me the flexibility to query particular attendeeId and change the entire JSON associated with that. Even though, this is a redundant step, I do not want to spend extra bucks on my hobby project.

提交回复
热议问题