entc/gen: simplify the way to get gen.Field operation

External templates should not deal with storage configuration
This commit is contained in:
Ariel Mashraki
2021-06-27 10:50:25 +03:00
committed by Ariel Mashraki
parent ded20a0e36
commit d3a0b89864
11 changed files with 63 additions and 55 deletions

View File

@@ -54,7 +54,7 @@ in the LICENSE file in the root directory of this source tree.
{{ with $.NumM2M }}
var (
{{- range $_, $e := $.Edges }}
{{- range $e := $.Edges }}
{{- if $e.M2M }}
// {{ $e.PKConstant }} and {{ $e.ColumnConstant }}2 are the table columns denoting the
// primary key for the {{ $e.Name }} relation (M2M).

View File

@@ -22,9 +22,9 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
cfg.driver = &txDriver{tx: tx, drv: c.driver}
return &Tx{
config: cfg,
{{ range $_, $n := $.Nodes -}}
{{- range $n := $.Nodes }}
{{ $n.Name }}: New{{ $n.Name }}Client(cfg),
{{ end -}}
{{- end }}
}, nil
}
{{ end }}