updating a JSON array in AWS dynamoDB
<p>My document looks like this:</p>

<pre><code>{
  "data": {
      "eventId": "20161029125458-df-d",
      "name": "first",
      "purpose": "test",
      "location": "yokohama",
      "dateArray": [],
      "attendees": [
        {
          "attendeeId": "2016102973634-df",
          "attendeeName": "lakshman",
          "personalizedDateSelection": {}
        },
        {
          "attendeeId": "2016102973634-tyyu",
          "attendeeName": "diwaakar",
          "personalizedDateSelection": {}
        }
      ]
    }
}
</code></pre>

<p>Say, I need to update the attendee JSON array with <strong>attendeeId: 2016102973634-df</strong>. I tried many ways ways using <strong>update and condition expression</strong>, but no success.</p>

<p>Here is my try:</p>

<pre><code>const params = {
  TableName: "event",
  Key: {
    "eventId": eventId 
  },
  UpdateExpression: "SET attendees[???] = ",
  ConditionExpression: attendees.attendeeId = "2016102973634-df", 
  ExpressionAttributeValues: {
    ":attendee" : attendeeList
  },
  ReturnValues: "ALL_NEW"
};


dynamo.update(params, (err, data) =&gt; {
  if (err) {
    return reject(err);
  }
  console.log(data.Attributes);
});
</code></pre>

<p>Could not find any resources for updating an Json in a array.</p>

<p>After @notionquest's comment:
- Have not used any JsonMarshaller. Initially I added the empty array to attendees field like this:</p>

<pre><code>{
  "eventId": "20161029125458-df-d",
  "name": "first",
  "purpose": "test",
  "location": "yokohama",
  "dateArray": [],
  "attendees": []
}
</code></pre>

<p>and then When a new <strong>attendee</strong> comes I add it to the <strong>attendees</strong> property like this:</p>

<pre><code>const attendee = {
  "attendeeName": "user1",
  "personalizedDateSelection": {"today": "free"}
}
const attendeeList = [attendee];
const eventId = "20161029125458-df-d";


const params = {
  TableName: "event",
  Key: {
    "eventId": eventId
  },
  UpdateExpression: "SET attendees = list_append(attendees, :attendee)",
  ExpressionAttributeValues: {
    ":attendee" : attendeeList
  },
  ReturnValues: "ALL_NEW"
};


dynamo.update(params, (err, data) =&gt; {
  if (err) {
    return reject(err);
  }
  console.log("in update dynamo");
  console.log(data.Attributes);
});
</code></pre>

<p>As you have seen in the above snippets, initially I add empty <strong>[] array</strong> and add a <strong>new attendee using the above code</strong>. Now, How do I update a specific JSON in an array. If you say that is not possible, what else can I try? </p>

<p>Should I try this :</p>

<ol>
<li>Get the Full JSON.</li>
<li>Manipulate the JSOn and change the things I want in my nodeJS.</li>
<li>And then update the new JSON to dynamoDB.</li>
<li>But this consumes two calls to dynamoDB which seems to be inefficient.</li>
</ol>

<p>Would like to know If there is any round way ?</p>