mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
committed by
Ariel Mashraki
parent
dd4d2521a7
commit
81eeefa6a2
21
entc/integration/template/ent/template/helper.tmpl
Normal file
21
entc/integration/template/ent/template/helper.tmpl
Normal file
@@ -0,0 +1,21 @@
|
||||
{{/*
|
||||
Copyright 2019-present Facebook Inc. All rights reserved.
|
||||
This source code is licensed under the Apache 2.0 license found
|
||||
in the LICENSE file in the root directory of this source tree.
|
||||
*/}}
|
||||
|
||||
{{/* The line below tells Intellij/GoLand to enable the autocompletion based *gen.Graph type. */}}
|
||||
{{/* gotype: entgo.io/ent/entc/gen.Graph */}}
|
||||
|
||||
{{ define "helper/one" }}
|
||||
{{ range $n := $.Nodes }}
|
||||
{{/* Non empty global helper template. */}}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
{{ define "helper/two" }}
|
||||
{{ range $n := $.Nodes }}
|
||||
{{/* Non empty global helper template. */}}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
@@ -164,6 +164,17 @@ func (t *tables) Load(ctx context.Context, querier querier) ([]string, error) {
|
||||
return tables, err
|
||||
}
|
||||
|
||||
{{ template "node/helper/loadtable" $ }}
|
||||
|
||||
{{ end }}
|
||||
|
||||
{{ define "client/fields/additional" }}
|
||||
// additional fields for node api
|
||||
tables tables
|
||||
{{ end }}
|
||||
|
||||
{{/* An example of a local helper template. */}}
|
||||
{{ define "node/helper/loadtable" }}
|
||||
func (tables) load(ctx context.Context, querier querier) ([]string, error) {
|
||||
rows := &sql.Rows{}
|
||||
query, args := sql.Select("type").
|
||||
@@ -177,9 +188,4 @@ func (tables) load(ctx context.Context, querier querier) ([]string, error) {
|
||||
var tables []string
|
||||
return tables, sql.ScanSlice(rows, &tables)
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
{{ define "client/fields/additional" }}
|
||||
// additional fields for node api
|
||||
tables tables
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
Reference in New Issue
Block a user