Skip to content

Commit

Permalink
feat: gen model export WithSession
Browse files Browse the repository at this point in the history
  • Loading branch information
smithyj committed Oct 18, 2023
1 parent 423597a commit 1f58fce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tools/goctl/model/sql/template/tpl/model-new.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ func (m *default{{.upperStartCamelObject}}Model) withSession(session sqlx.Sessio
table: {{.table}},
}
}

func (m *default{{.upperStartCamelObject}}Model) WithSession(session sqlx.Session) *default{{.upperStartCamelObject}}Model {
return &default{{.upperStartCamelObject}}Model{
{{if .withCache}}CachedConn:m.CachedConn.WithSession(session){{else}}conn:sqlx.NewSqlConnFromSession(session){{end}},
table: {{.table}},
}
}
1 change: 1 addition & 0 deletions tools/goctl/model/sql/template/tpl/types.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
type (
{{.lowerStartCamelObject}}Model interface{
{{.method}}
WithSession(session sqlx.Session) *default{{.upperStartCamelObject}}Model
}

default{{.upperStartCamelObject}}Model struct {
Expand Down

0 comments on commit 1f58fce

Please sign in to comment.