mirror of
https://github.com/ent/ent.git
synced 2026-05-28 09:49:08 +03:00
upload first, then store the key as virtual fk
This commit is contained in:
@@ -53,6 +53,9 @@ in the LICENSE file in the root directory of this source tree.
|
||||
{{ $f.Constant }},
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- range $bk := $.BlobKeys }}
|
||||
"{{ $bk.Field.Name }}",
|
||||
{{- end }}
|
||||
}
|
||||
{{/* If any of the edges owns a foreign-key */}}
|
||||
{{ with $.UnexportedForeignKeys }}
|
||||
@@ -65,6 +68,23 @@ in the LICENSE file in the root directory of this source tree.
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
{{ with $.BlobKeys }}
|
||||
// BlobKeys holds the SQL columns for blob storage keys.
|
||||
var BlobKeys = []string{
|
||||
{{- range $bk := . }}
|
||||
"{{ $bk.Field.Name }}",
|
||||
{{- end }}
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
{{- range $f := $.BlobFields }}
|
||||
{{- if $f.HasBlobKey }}
|
||||
// {{ $f.BlobKeyName }} generates the blob storage key for the {{ $f.Name }} field.
|
||||
// It is set by the runtime/init package from the schema descriptor.
|
||||
var {{ $f.BlobKeyName }} func(context.Context) (string, error)
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{ with $.NumM2M }}
|
||||
var (
|
||||
{{- range $e := $.Edges }}
|
||||
@@ -94,6 +114,13 @@ func ValidColumn(column string) bool {
|
||||
}
|
||||
}
|
||||
{{- end }}
|
||||
{{- with $.BlobKeys }}
|
||||
for i := range BlobKeys {
|
||||
if column == BlobKeys[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
{{- end }}
|
||||
{{- with $.DeprecatedFields }}
|
||||
for _, f := range [...]string{ {{- range . }}{{ .Constant }},{{ end }} } {
|
||||
if column == f {
|
||||
|
||||
Reference in New Issue
Block a user