I am trying to delete all items from an aws dynamodb table by hashkey. I see alot of discussion about it on the internet but no actual code samples and all my attempts have failed.
What am I doing wrong here or is there a better apporach altogether?
List<Document> results = null;
var client = new AmazonDynamoDBClient("myamazonkey", "myamazonsecret");
var table = Table.LoadTable(client, "mytable");
var search = table.Query(new Primitive("hashkey"), new RangeFilter());
do {
results = search.GetNextSet();
search.Matches.Clear();
foreach (var r in results)
{
client.DeleteItem(new DeleteItemRequest()
{
Key = new Key() { HashKeyElement = new AttributeValue() { S = "hashkey"}, RangeKeyElement = new AttributeValue() { N = r["range-key"].AsString() } }
});
}
} while(results.Count > 0);