MCPcopy
hub / github.com/pocketbase/pocketbase / initEmailField

Method initEmailField

core/collection_model.go:1029–1054  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1027}
1028
1029func (c *Collection) initEmailField() {
1030 field, _ := c.Fields.GetByName(FieldNameEmail).(*EmailField)
1031 if field == nil {
1032 // load default field
1033 c.Fields.Add(&EmailField{
1034 Name: FieldNameEmail,
1035 System: true,
1036 Required: true,
1037 })
1038 } else {
1039 // enforce system defaults
1040 field.System = true
1041 field.Hidden = false // managed by the emailVisibility flag
1042 }
1043
1044 // ensure that there is a unique index for the email field
1045 if _, ok := dbutils.FindSingleColumnUniqueIndex(c.Indexes, FieldNameEmail); !ok {
1046 c.Indexes = append(c.Indexes, fmt.Sprintf(
1047 "CREATE UNIQUE INDEX `%s` ON `%s` (`%s`) WHERE `%s` != ''",
1048 c.fieldIndexName(FieldNameEmail),
1049 c.Name,
1050 FieldNameEmail,
1051 FieldNameEmail,
1052 ))
1053 }
1054}
1055
1056func (c *Collection) initEmailVisibilityField() {
1057 field, _ := c.Fields.GetByName(FieldNameEmailVisibility).(*BoolField)

Callers 1

initDefaultFieldsMethod · 0.95

Calls 4

fieldIndexNameMethod · 0.95
GetByNameMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected