I've created my second clojar and would love any feedback: 
https://github.com/flyingmachine/serialize. It's a tiny library for 
serializing datomic entities (though maybe it should be called "mapify" 
instead of "serialize"). Here's an example of it in use:

(defserializer ent->topic
  (attr :id :db/id)
  (attr :title :topic/title)
  (has-many :posts
            :serializer example.serializers/ent->post
            :retriever #(datomic-magic/all [:post/topic (:db/id %)])))

=> (def t1 (datomic-magic/one :topic/title "First topic"))
=> (serialize t1 example.serializers/ent->topic)
{:id 1000
 :title "First Topic"}

;; When we :include a relationship, it's included in the result. Hey,
;; how bout that wow
=> (serialize t1 example.serializers/ent->topic {:include :posts})
{:id 1000
 :title "First Post"
 :posts [{:id 1001
          :content "T1 First post content"}
         {:id 1002
          :content "T1 Second post content"}]}

I hope someone finds this useful :)

Daniel

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to