Yes, my suggestion without type indicators in SDB would look something
like this:
(def config {:sdb-client (AmazonSimpleDBClient. ...)
:mapping {"Link" {"url" {:encode encode-string :decode
decode-string}
"points" sdb/integer-encoding
"date" {:encode encode-jodadate :decode
decode-jodadate}}
"AnotherDomain" {...}})
sdb/integer-encoding would be a library provided encoding/decoding
map.
In this approach each encoding/decoding pair is defined at the level
of an attribute in a domain.
A (get-attr config "Link" "id") will go through the mapping in the
config to create a clojure datastructure with each attr properly
decoded.
A mapping map would allow for a bit more composition then one big
encode fn in the config where a case construct needs to be extended
for each attribute. For instance the mapping could be constructed like
this: {:mapping (merge link-domain-map another-domain-map ...)}.
Perhaps a library could provide a macro that expands (defdomain Link
[url :string, point :int, date {:encode .. :decode ..}]) into such a
mapping map.
Because this approach doesn't have any type indicators in SDB, every
attribute needs to have an encoding/decoding defined or there needs to
be a default encode/decoding, which for Clojure could be print-string/
read-string.
-Gijs
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en