Describe the feature
Would please simplify the relation mapping between tables like SqlAlchemy.
for example:
class Collection(Base):
__tablename__ = "collction"
id = Column(Integer, primary_key=True, autoincrement=True)
name= Column(String(100), nullable=False)
class Document(Base):
__tablename__ = "document"
id = Column(Integer, primary_key=True, autoincrement=True)
# foreign key to collection
document_id = Column(Integer , ForeignKey("collection.id", ondelete="CASCADE"))
Golang example:
type Collection struct {
Base
Name string `gorm:"type:varchar(100) not null" json:"name"`
}
type Document struct {
Base
DocumentId int64 `gorm:"type:bigint not null;fk:Collection.Id,ondelete=CASCADE" json:"documentId"`
}
Motivation
belong,one2one,one2many, many2many are useless on most cases and add much complexity to the project. Please let developers to build relations in the code.
Reasons:
1. The records of tables are offen cache in the redis. It means one2one,one2many,many2many are no need.
2. many2many is useless. The middle table offen has other column, and the middle table maybe has more than 2 foreigner keys.
3. Please forget Java ORM in golang. be light.
Related Issues
Comment From: github-actions[bot]
This issue has been automatically marked as stale because it has been open 360 days with no activity. Remove stale label or comment or this will be closed in 180 days