upload first, then store the key as virtual fk

This commit is contained in:
Giau. Tran Minh
2026-05-05 15:27:47 +00:00
parent 39bcbbc359
commit 6802bf68f8
30 changed files with 539 additions and 685 deletions

View File

@@ -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 {