diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2014-07-26 21:57:18 -0700 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2014-07-26 21:57:18 -0700 |
commit | cbdd0be404d61edde1ef4b1abc582565d3843a70 (patch) | |
tree | 31ee23f2cba60b9bf86e5fb22956212f48084b80 /src/com | |
parent | 512d760729edae5cdfee465eab7244fa153070db (diff) |
Adding a delete option to the DbTool.
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/p4square/grow/backend/dynamo/DbTool.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/com/p4square/grow/backend/dynamo/DbTool.java b/src/com/p4square/grow/backend/dynamo/DbTool.java index e030caf..581795d 100644 --- a/src/com/p4square/grow/backend/dynamo/DbTool.java +++ b/src/com/p4square/grow/backend/dynamo/DbTool.java @@ -44,6 +44,7 @@ public class DbTool { System.out.println("\t--drop <table> Delete a table"); System.out.println("\t--get <table> <key> <attribute> Get a value"); System.out.println("\t--put <table> <key> <attribute> <value> Put a value"); + System.out.println("\t--delete <table> <key> <attribute> Delete a value"); System.out.println(); System.out.println("Bootstrap Commands:"); System.out.println("\t--bootstrap <data> Create all tables and import all data"); @@ -99,6 +100,9 @@ public class DbTool { } else if ("--put".equals(args[offset])) { offset = put(args, ++offset); + } else if ("--delete".equals(args[offset])) { + offset = delete(args, ++offset); + /* Bootstrap Commands */ } else if ("--bootstrap".equals(args[offset])) { if ("dev".equals(mConfig.getDomain())) { @@ -203,6 +207,20 @@ public class DbTool { return offset; } + private static int delete(String[] args, int offset) { + String table = args[offset++]; + String key = args[offset++]; + String attribute = args[offset++]; + + DynamoDatabase db = getDatabase(); + + db.deleteAttribute(DynamoKey.newAttributeKey(table, key, attribute)); + + System.out.printf("Deleted %s %s:%s\n\n", table, key, attribute); + + return offset; + } + private static int bootstrapTables(String[] args, int offset) { DynamoDatabase db = getDatabase(); |