MCPcopy
hub / github.com/Wei-Shaw/sub2api / SetField

Method SetField

backend/ent/mutation.go:1713–1878  ·  view source on GitHub ↗

SetField sets the value of a field with the given name. It returns an error if the field is not defined in the schema, or if the type mismatched the field type.

(name string, value ent.Value)

Source from the content-addressed store, hash-verified

1711// the field is not defined in the schema, or if the type mismatched the field
1712// type.
1713func (m *APIKeyMutation) SetField(name string, value ent.Value) error {
1714 switch name {
1715 case apikey.FieldCreatedAt:
1716 v, ok := value.(time.Time)
1717 if !ok {
1718 return fmt.Errorf("unexpected type %T for field %s", value, name)
1719 }
1720 m.SetCreatedAt(v)
1721 return nil
1722 case apikey.FieldUpdatedAt:
1723 v, ok := value.(time.Time)
1724 if !ok {
1725 return fmt.Errorf("unexpected type %T for field %s", value, name)
1726 }
1727 m.SetUpdatedAt(v)
1728 return nil
1729 case apikey.FieldDeletedAt:
1730 v, ok := value.(time.Time)
1731 if !ok {
1732 return fmt.Errorf("unexpected type %T for field %s", value, name)
1733 }
1734 m.SetDeletedAt(v)
1735 return nil
1736 case apikey.FieldUserID:
1737 v, ok := value.(int64)
1738 if !ok {
1739 return fmt.Errorf("unexpected type %T for field %s", value, name)
1740 }
1741 m.SetUserID(v)
1742 return nil
1743 case apikey.FieldKey:
1744 v, ok := value.(string)
1745 if !ok {
1746 return fmt.Errorf("unexpected type %T for field %s", value, name)
1747 }
1748 m.SetKey(v)
1749 return nil
1750 case apikey.FieldName:
1751 v, ok := value.(string)
1752 if !ok {
1753 return fmt.Errorf("unexpected type %T for field %s", value, name)
1754 }
1755 m.SetName(v)
1756 return nil
1757 case apikey.FieldGroupID:
1758 v, ok := value.(int64)
1759 if !ok {
1760 return fmt.Errorf("unexpected type %T for field %s", value, name)
1761 }
1762 m.SetGroupID(v)
1763 return nil
1764 case apikey.FieldStatus:
1765 v, ok := value.(string)
1766 if !ok {
1767 return fmt.Errorf("unexpected type %T for field %s", value, name)
1768 }
1769 m.SetStatus(v)
1770 return nil

Callers

nothing calls this directly

Calls 15

SetCreatedAtMethod · 0.95
SetUpdatedAtMethod · 0.95
SetDeletedAtMethod · 0.95
SetUserIDMethod · 0.95
SetKeyMethod · 0.95
SetNameMethod · 0.95
SetGroupIDMethod · 0.95
SetStatusMethod · 0.95
SetLastUsedAtMethod · 0.95
SetIPWhitelistMethod · 0.95
SetIPBlacklistMethod · 0.95
SetQuotaMethod · 0.95

Tested by

no test coverage detected