// Example multiple item deletes when using "BatchWriteItem" statically (e.g., not passing an array)
//	params = {
//		RequestItems: {
//			"test": [
//			    {
//					"DeleteRequest": {
//					    "Key": { "testid": { "N": "1" } }
//					}
//			    },
//			    {
//					"DeleteRequest": {
//					    "Key": { "testid": { "N": "2" } }
//					}
//			    }
//			]
//		},
//		ReturnConsumedCapacity: "NONE",
//		ReturnItemCollectionMetrics: "NONE"
//	};

// Build code block to perform multiple deletes when using "BatchWriteItem" dynamically
var AWS = require("aws-sdk");
var batClient = new AWS.DynamoDB();
var params = {};

exports.handler = function(event, context) {
	delKeys = [];
	for (var d = 0; d < 3; d++) {
		// Adding multiple items to be deleted when using "BatchWriteItem".  "testid" is the column (or "attribute") name.
		if (d === 1) {
			delKeys[delKeys.length] = { "DeleteRequest": { "Key": { "testid": { "N": d.toString() } } } };
		}
		if (d === 2) {
			delKeys[delKeys.length] = { "DeleteRequest": { "Key": { "testid": { "N": d.toString() } } } };
		}
	}

	// Build query to perform the multiple deletes when using "BatchWriteItem".  "test" is the table name.
	params = {
		RequestItems: {
			"test": delKeys
		},
		ReturnConsumedCapacity: "NONE",
		ReturnItemCollectionMetrics: "NONE"
	};

	// Run the query
	batClient.batchWriteItem(params, function(err, data) {
		if (err) {
			context.done(
				null,
				{
				"result": JSON.stringify(err, null, 2)
				}
			);
		}
		else {
			context.done(
				null,
				{
				"result": "Check to see if rows 1, 2 were removed."
				}
			);
		}
	});

};
