title: How to delete entry in dynamodb list?
body: <p>I've got a lambda function, which acts as a trigger on a table with best scores of users to handle a leaderboard table.</p>
  
  <p>In my leaderboard table, the sort key is the score, and the player's name is a separate entry with a list, because it's possible that there could be more than one player with the same score. Never mind.</p>
  
  <p>So when adding a player I do:</p>
  
  <pre><code>var paramsNewEntry = {
              "TableName": leaderboardTable,
              "Key": {
                  "trackId": trackId,
                  "time": newValue
              },
              "UpdateExpression": "SET players = list_append(if_not_exists(players, :emptyList), :playersList),
              "ExpressionAttributeValues": {
                  ":playersList": [userId],
                  ":emptyList":[]
              },
              "ReturnValues": "NONE"
          };
  </code></pre>
  
  <p>And this works fine. I wanted to remove it this way:</p>
  
  <pre><code>var paramsOldEntry = {
                      "TableName": myTable,
                      "Key": {
                          "trackId": trackId,
                          "time": oldValue
                      },
                      "UpdateExpression": "DELETE players :playerToRemove",
                      "ExpressionAttributeValues": {
                          ":playerToRemove": [userId]
                      },
                      "ReturnValues": "ALL_NEW"
                  }
  </code></pre>
  
  <p>But I get: <code>Invalid UpdateExpression: Incorrect operand type for operator or function; operator: DELETE, operand type: LIST</code> error.</p>
  
  <p>The <code>players</code> attribute is a list, query response example:</p>
  
  <pre><code>{
    "Items": [
      {
        "time": {
          "N": "99994"
        },
        "players": {
          "L": [
            {
              "S": "krystianPostman2"
            }
          ]
        },
        "trackId": {
          "S": "betaTrack001"
        }
      }
    ],
    "Count": 1,
    "ScannedCount": 1,
    "LastEvaluatedKey": {
      "time": {
        "N": "99994"
      },
      "trackId": {
        "S": "betaTrack001"
      }
    }
  }
  </code></pre>
  
  <p>I've not seen any question on SO which would provide any details on this in javascript, when using the dynamodb Document API.</p>