MCPcopy
hub / github.com/pocketbase/pocketbase / CustomData

Method CustomData

core/record_model.go:790–818  ·  view source on GitHub ↗

CustomData returns a shallow copy ONLY of the custom record fields data, aka. fields that are neither defined by the collection, nor special system ones. Note that custom fields prefixed with "@pbInternal" are always skipped.

()

Source from the content-addressed store, hash-verified

788//
789// Note that custom fields prefixed with "@pbInternal" are always skipped.
790func (m *Record) CustomData() map[string]any {
791 if m.data == nil {
792 return nil
793 }
794
795 fields := m.Collection().Fields
796
797 knownFields := make(map[string]struct{}, len(fields))
798
799 for _, f := range fields {
800 knownFields[f.GetName()] = struct{}{}
801 }
802
803 result := map[string]any{}
804
805 rawData := m.data.GetAll()
806 for k, v := range rawData {
807 if _, ok := knownFields[k]; !ok {
808 // skip internal custom fields
809 if strings.HasPrefix(k, internalCustomFieldKeyPrefix) {
810 continue
811 }
812
813 result[k] = v
814 }
815 }
816
817 return result
818}
819
820// WithCustomData toggles the export/serialization of custom data fields
821// (false by default).

Callers 3

TestRecordCustomDataFunction · 0.95
PublicExportMethod · 0.95
TestRecordUpsertLoadFunction · 0.80

Calls 3

CollectionMethod · 0.95
GetNameMethod · 0.65
GetAllMethod · 0.45

Tested by 2

TestRecordCustomDataFunction · 0.76
TestRecordUpsertLoadFunction · 0.64