Get the latest version on Clojars
A WIP attempt to write a DSL for DynamoDB expressions in Clojure. Not ready for real-world use yet!
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.Modifying.html
To test condition expressions without nasty string hacking, there’s a grammar for condition expressions, based on the documentation.
This much pretty much works…
(ns foo
(:require [dynamodb-expressions :as dx]))
(def x 4)
(dx/expr
'(dx/add ["foo.bar" x]
["bar.baz" 8])
'(dx/add ["-goof-" 76]))
#_({:update-expression "ADD #foo_bar_G__22528 :x_G__22529, #bar_baz_G__22530 :8_G__22531",
:expression-attribute-names {"#foo_bar_G__22528" "foo.bar",
"#bar_baz_G__22530" "bar.baz",
"#__goof__G__22532" "-goof-"},
:expression-attribute-values {":x_G__22529" 4,
":8_G__22531" 8,
":76_G__22533" 76}})
Next steps to extend the syntax out to set, remove, delete, and tidy up the syntax, something like:
(dx/expr
(dx/add ["a" x]
["b" 8])
(dx/set (dx/+ "c" 76)
(dx/= "d" "foo bar"))
(dx/remove "e" "f" "g")
(dx/delete ["h" "baz"]))
Copyright © 2016 Paul Brabban
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.