Note that there are some explanatory texts on larger screens.

plurals
  1. POORM for clojure?
    text
    copied!<p>I was reading this site about the clojure web stack: </p> <p><a href="http://brehaut.net/blog/2011/ring_introduction" rel="noreferrer">http://brehaut.net/blog/2011/ring_introduction</a></p> <p>and it has this to say about ORM for clojure:</p> <p>"There are no SQL/Relational DB ORMs for Clojure for obvious reasons."</p> <p>The obvious reason I can see is that the mapping to object happens automatically when you do a clojure.contrib.sql or clojureql query. However it seems some extra work is needed to do one-to-many or many-to-many relations (although maybe not too much work). </p> <p>I found this write up for one-to-many: <a href="http://briancarper.net/blog/493/" rel="noreferrer">http://briancarper.net/blog/493/</a></p> <p>Which I'm not sure I agree with; it appears to be assuming that both tables are pulled from the database and then the joined table is filtered in memory. In practice I think the sql query would specify the where criteria.</p> <p>So I'm left wondering, is there some fairly obvious way to automatically do one-to-many relations via clojureql or clojure.contrib.sql? The only thing I can think of is something like this (using the typical blog post/comment example):</p> <pre><code>(defn post [id] @(-&gt; (table :posts) (select (where :id id)))) (defn comments [post_id] @(-&gt; (table :comments) (select (where :post_id post_id)))) (defn post-and-comments [id] (assoc (post id) :comments (comments id))) </code></pre> <p>Is there any way to sort of automate this concept or is this as good as it gets?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload