Open hxzon opened 9 years ago
i know i can do it by this way:
(defmacro defentity-material [ent-name alias pk] `(defentity ~ent-name (pk ~pk) (table :material ~alias) (entity-fields :id :createtime :updatetime :brand :code ) (belongs-to material-origfile {:pk :origfile_id}) ) )
(defentity-material material :material :id) (defentity-material material-2 :material :code)
(defentity bom-material (pk :id) (table :bommaterial :bom-material) (entity-fields :id :createtime :updatetime :code :comment :designator :footprint :quantity :stuffopt :value :voltage :bom_id) (belongs-to bom {:fk :bom_id}) (belongs-to material-2 {:fk :code }) )
It work.
Another option would be to join
instead of with
, which allows you to define arbitrary join condition.
(defentity material (pk :id:) (entity-fields :id :code) ) (defentity bom-material (pk :id) (table :bommaterial :bom-material) (entity-fields :id :createtime :updatetime :code :comment :bom_id) (belongs-to bom {:fk :bom_id}) (belongs-to material {:fk :code :pk :code});; i wan't set :pk here to override default ) 我希望在 belongs-to 处可以设置 pk,来覆盖默认的 pk 。