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)
| 1711 | // the field is not defined in the schema, or if the type mismatched the field |
| 1712 | // type. |
| 1713 | func (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 |
nothing calls this directly
no test coverage detected