Skip to content

Commit

Permalink
feat: session method for relation field (go-gorm#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andello authored Apr 12, 2023
1 parent 6df282a commit e9e31a7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/template/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ func (a {{$.QueryStructName}}{{$relationship}}{{$relation.Name}}) WithContext(ct
return &a
}
func (a {{$.QueryStructName}}{{$relationship}}{{$relation.Name}}) Session(session *gorm.Session) *{{$.QueryStructName}}{{$relationship}}{{$relation.Name}} {
a.db = a.db.Session(session)
return &a
}
func (a {{$.QueryStructName}}{{$relationship}}{{$relation.Name}}) Model(m *{{$.StructInfo.Package}}.{{$.StructInfo.Type}}) *{{$.QueryStructName}}{{$relationship}}{{$relation.Name}}Tx {
return &{{$.QueryStructName}}{{$relationship}}{{$relation.Name}}Tx{a.db.Model(m).Association(a.Name())}
}
Expand Down

0 comments on commit e9e31a7

Please sign in to comment.