Hey!

i hope this is the right place to ask this question! Here it goes: I want 
to create a simple model with cariou that references itself to generate a 
tree-structure. Like this:

(defn category []
    (model/create :model {:name "category" 
                        :fields [{:name "Label" :type "string"}
                                 {:name "related-categories" :type "link"
                                   :target-id (model/models :category :id)
                                   :reciprocal-name 
"relating-categories"}]}))

This results in a:

DEBUG :db insert into field values dependent = false, slug = 
'relating-categories', position = 201, map = false, localized = false, name 
= 'relating-categories', locked = false, model-id = '', target-id = 22, 
uuid = '13776b59-7359-4412-850f-ffaa619665e0', type = 'link', updated-at = 
'2014-02-04 09:53:48.578', model-position = 201, link-id = 380, 
status-position = 139
Exception in thread "main" org.h2.jdbc.JdbcSQLException: NULL not allowed 
for column "MODEL_ID"; SQL statement:
INSERT INTO field 
(dependent,slug,position,map,localized,name,locked,model_id,target_id,uuid,type,updated_at,model_position,link_id,status_position)
 
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) [23502-170]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
    at org.h2.message.DbException.get(DbException.java:169)
    at org.h2.message.DbException.get(DbException.java:146)
    at org.h2.table.Column.validateConvertUpdateSequence(Column.java:293)...

Because the category to be reference is not yet available. Is there a way 
to create a model and afterwards update it with constraints (Like you would 
do in SQL)!?

Btw. naturally the other way around will dont work either:

(defn category []
    (model/create :model {:name "category" 
                        :fields [{:name "Label" :type "string"}
                                 {:name "keywords" :type "string"}
                                 {:name "parent-category" :type "part"
                                   :target-id (model/models :category :id)
                                   :reciprocal-name "child-categories"}]}))

And the bidirectional (or in caribou-speech: "reciprocal") also not: 

(defn category []
    (model/create :model {:name "category" 
                        :fields [{:name "Label" :type "string"}
                                 {:name "keywords" :type "string"}
                                 {:name "parent-category" :type "link"
                                   :target-id (model/models :category 
:id)}]}))

Any hints? Btw. Caribou is really pragmatic, fast and clean, love it! 
NoSQL/Riak support would awesome too!

Thanks and regards,
David

-- 
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/groups/opt_out.

Reply via email to