MCPcopy
hub / github.com/pocketbase/pocketbase / FindFileFieldByFile

Method FindFileFieldByFile

core/record_model.go:1076–1094  ·  view source on GitHub ↗

FindFileFieldByFile returns the first file type field for which any of the record's data contains the provided filename.

(filename string)

Source from the content-addressed store, hash-verified

1074// FindFileFieldByFile returns the first file type field for which
1075// any of the record's data contains the provided filename.
1076func (m *Record) FindFileFieldByFile(filename string) *FileField {
1077 for _, field := range m.Collection().Fields {
1078 if field.Type() != FieldTypeFile {
1079 continue
1080 }
1081
1082 f, ok := field.(*FileField)
1083 if !ok {
1084 continue
1085 }
1086
1087 filenames := m.GetStringSlice(f.GetName())
1088 if slices.Contains(filenames, filename) {
1089 return f
1090 }
1091 }
1092
1093 return nil
1094}
1095
1096// DBExport implements the [DBExporter] interface and returns a key-value
1097// map with the data to be persisted when saving the Record in the database.

Callers 2

downloadMethod · 0.80

Calls 4

CollectionMethod · 0.95
GetStringSliceMethod · 0.95
TypeMethod · 0.65
GetNameMethod · 0.65

Tested by 1