add object to map in dynamo db

I am trying to add an element to an existing MAP object in dynamo db, but for some reason when I ran this I added a new column instead. What is wrong with this query? My table structure is:

topic      questions
-----      ----------
Dynamo     { "what is Dynamo?" : { "S" : "x" }  }

code:

var params = {
  TableName: TABLE_NAME,
  Key: { topic: topic },
  UpdateExpression: "ADD #qq = :ans",
  ExpressionAttributeNames: {
    "#qq": qq,
  },
  ExpressionAttributeValues: {
    ":ans": { S: ans },
  },
};
let res = await docClient.update(params).promise();

Answer

ADD is used for numbers and Set, not for MAP.

To append an element to a MAP, we need to use SET.

const TABLE_NAME = "test";
const topic = "Dynamo";
const qq = "what is Dynamo?";
const answer = "its a nosql database";
docClient.update(
  {
    TableName: TABLE_NAME,
    Key: {
      topic: topic,
    },
    UpdateExpression: "set questions.#qq = :answer",
    ExpressionAttributeValues: {
      ":answer": answer,
    },
    ExpressionAttributeNames: {
      "#qq": qq,
    },
  },
  function (error, result) {
    console.log("error", error, "result", result);
  }
);