On Tuesday, 26 May 2015 06:43:18 UTC+10, Krzysiek Herod wrote:
>
> Sean, maybe my use case is specific to web applications. In REST API's 
> it's common to respond with something like "Example Result" here: 
> https://dev.twitter.com/rest/reference/get/statuses/mentions_timeline I 
> completely agree with you about ORMs, but in case of REST API's one just 
> needs to somehow map the queryset to a structure of hashes and arrays (not 
> necessarily objects), and this task is much heavier than I thought in the 
> beginning, from choosing between making many queries to fill in the hash of 
> related objects vs making JOINs, to complexity of extracting data from a 
> set of rows with potential repetitions, rows of null values (like Daniel 
> said happens for instance in case of LEFT JOINS), and different kinds of 
> relations (has-one, has-many, belongs-to). 
>

I found myself needing this for a REST API as well, so I implemented an 
'unjoin' function which sounds like what you're looking for.

Here's a gist, including test case (not necessarily a hugely comprehensive 
test case, but better than nothing): 
 https://gist.github.com/samroberton/d72cedaf225526d9007a

It's working for me for the few use cases I have for it -- I'd be 
interested to hear whether it works for you too.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to