snapshot of https://github.com/ent/ent.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
Atlas CI Public / lint (push) Failing after 13s
Atlas CI Public / sync (push) Has been skipped

This commit is contained in:
upstream-mirror
2026-09-15 22:12:36 +05:00
commit 4b3ad0b611
2680 changed files with 719472 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
{{/*
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.
*/}}
{{ define "client/additional/driver/dialect" }}
// Dialect returns the driver dialect.
func(c *Client) Dialect() string {
return c.driver.Dialect()
}
// Driver returns the underlying driver.
func(c *Client) Driver() dialect.Driver {
return c.driver
}
{{ end }}

View File

@@ -0,0 +1,14 @@
// 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.
package template
// Extension is a template extension.
type Extension struct {
Type string
}
func (*Extension) Name() string {
return "Extension"
}

View File

@@ -0,0 +1,33 @@
{{/*
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.
*/}}
{{ define "extension" }}
{{ $pkg := base $.Config.Package }}
{{ template "header" $ }}
{{ range $n := $.Nodes }}
{{ $hasExt := false }}
{{ range $f := $n.Fields }}{{ if $f.Annotations.Extension }}{{ $hasExt = true }}{{ end }}{{ end }}
{{ range $e := $n.Edges }}{{ if $e.Annotations.Extension }}{{ $hasExt = true }}{{ end }}{{ end }}
{{/* If one or fields contain the "Extension" annotation */}}
{{ if $hasExt }}
// {{ $n.Name }}Extension is a type for holding the extension information defined in the schema.
type {{ $n.Name }}Extension struct {
{{- range $f := $n.Fields }}
{{- with $ant := $f.Annotations.Extension }}
{{ $f.StructField }} {{ $ant.Type }}
{{- end }}
{{- end }}
{{- range $e := $n.Edges }}
{{- with $ant := $e.Annotations.Extension }}
{{ $e.StructField }} {{ $ant.Type }}
{{- end }}
{{- end }}
}
{{ end }}
{{ end }}
{{ end }}

View File

@@ -0,0 +1,12 @@
{{/* A template for adding additional fields to specific types. */}}
{{ define "model/fields/additional" }}
{{- /* Add static fields to the "Card" entity. */}}
{{- if eq $.Name "Card" }}
// StaticField defined by templates.
StaticField string `json:"boring,omitempty"`
{{- end }}
{{ end }}
{{ define "client/fields/additional/node" }}
TemplateField struct{}
{{ end }}

View File

@@ -0,0 +1,25 @@
{{/*
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.
*/}}
{{/* A template for adding additional fields to specific types. */}}
{{ define "meta/additional/enums" }}
{{- range $f := $.EnumFields }}
{{- if not $f.HasGoType }}
{{ $enum := trimPackage $f.Type.String $.Package }}
{{ $receiver := receiver $f.BuilderField }}
// Ptr returns a new pointer to the enum value.
func ({{ $receiver }} {{ $enum }}) Ptr() *{{ $enum }} {
return &{{ $receiver }}
}
{{- end }}
{{- end }}
{{ end }}
{{ define "meta/additional/random" }}
// comment from another template.
{{ end }}