Beego: Orm: Composite Primary Key

Created on 8 Mar 2015  ·  12Comments  ·  Source: astaxie/beego

It seems that the Orm doesn't support Composite Primary Keys out of the box.

I have a model User as such:

type User struct{
   id int
   ...
}
with Primary Key "Id".

I also want to create the concept of Friends with the following model:
type Friends struct{
   Friend1 *User "orm:"rel(fk);pk""
   Friend2 *User "orm:"rel(fk);pk""
}
In effect creating the following table:

CREATE TABLE friends (
   friend1 REFERENCES(user)
   friend2 REFERENCES(user)
   PRIMARY KEY(friend1, friend2)
}

Is this a viable feature to implement or should I just go with another Id-index?

areorm kinproposal

Most helpful comment

+1

In the meantime, has anyone found a way to represent the composite pkey?

All 12 comments

+1

I would also like this feature.

+1

In the meantime, has anyone found a way to represent the composite pkey?

Does Beego offer Composite Primary Key yet?

https://github.com/awengo/beego/pull/1
准备开始完善这个功能,有什么好建议吗?目前只能暂时简单的添加复合主键
Ready to improve this feature, any good suggestions?
Currently just can simply add a composite primary key.

+1

3130

3221

+1

+1

+1

3 years has passed. Still not support?

+1

Was this page helpful?
0 / 5 - 0 ratings