title: How do I batch delete with DynamoDB?
body: <p>I am getting an error that "The provided key element does not match the schema". <code>uuid</code> is my primary partition key. I also have a primary sort key for <code>version</code>. I figured I can use <code>batchWrite</code> (<a href="http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#batchWrite-property" rel="noreferrer">docs</a>) to delete all items with same <code>uuid</code>.</p>
  
  <p>My ES6 code is as follows:</p>
  
  <pre><code>delete(uuid) {
    const promise = new Promise();
    const params = {
      RequestItems: {
        [this.TABLE]: [
          {
            DeleteRequest: {
              Key: { uuid: uuid }
            }
          }
        ]
      }
    };
  
  
    // this._client references the DocumentClient
    this._client.batchWrite(params, function(err, data) {
      if (err) {
        // this gets hit with error
        console.log(err);
        return promise.reject(err);
      }
  
      console.log(result);
      return promise.resolve(result);
    });
  
    return promise;
  }
  </code></pre>
  
  <p>Not sure why it is erroring on the key that is the primary. I have seen posts about needing other indexes for times when I am searching by something that isn't a key. But I don't believe that's the case here.</p>