// Code generated by ent, DO NOT EDIT. package models import ( "context" "errors" "fmt" "juwan-backend/app/users/rpc/internal/models/predicate" "juwan-backend/app/users/rpc/internal/models/schema" "juwan-backend/app/users/rpc/internal/models/users" "sync" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" ) const ( // Operation types. OpCreate = ent.OpCreate OpDelete = ent.OpDelete OpDeleteOne = ent.OpDeleteOne OpUpdate = ent.OpUpdate OpUpdateOne = ent.OpUpdateOne // Node types. TypeUsers = "Users" ) // UsersMutation represents an operation that mutates the Users nodes in the graph. type UsersMutation struct { config op Op typ string id *int64 username *string password_hash *string email *string phone *string nickname *string avatar *string bio *string current_role *string verified_roles *[]string appendverified_roles []string verificationStatus *schema.VerificationStatusStruct is_admin *bool created_at *time.Time updated_at *time.Time deleted_at *time.Time clearedFields map[string]struct{} done bool oldValue func(context.Context) (*Users, error) predicates []predicate.Users } var _ ent.Mutation = (*UsersMutation)(nil) // usersOption allows management of the mutation configuration using functional options. type usersOption func(*UsersMutation) // newUsersMutation creates new mutation for the Users entity. func newUsersMutation(c config, op Op, opts ...usersOption) *UsersMutation { m := &UsersMutation{ config: c, op: op, typ: TypeUsers, clearedFields: make(map[string]struct{}), } for _, opt := range opts { opt(m) } return m } // withUsersID sets the ID field of the mutation. func withUsersID(id int64) usersOption { return func(m *UsersMutation) { var ( err error once sync.Once value *Users ) m.oldValue = func(ctx context.Context) (*Users, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { value, err = m.Client().Users.Get(ctx, id) } }) return value, err } m.id = &id } } // withUsers sets the old Users of the mutation. func withUsers(node *Users) usersOption { return func(m *UsersMutation) { m.oldValue = func(context.Context) (*Users, error) { return node, nil } m.id = &node.ID } } // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. func (m UsersMutation) Client() *Client { client := &Client{config: m.config} client.init() return client } // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. func (m UsersMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("models: mutation is not running in a transaction") } tx := &Tx{config: m.config} tx.init() return tx, nil } // SetID sets the value of the id field. Note that this // operation is only accepted on creation of Users entities. func (m *UsersMutation) SetID(id int64) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. func (m *UsersMutation) ID() (id int64, exists bool) { if m.id == nil { return } return *m.id, true } // IDs queries the database and returns the entity ids that match the mutation's predicate. // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. func (m *UsersMutation) IDs(ctx context.Context) ([]int64, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { return []int64{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): return m.Client().Users.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } // SetUsername sets the "username" field. func (m *UsersMutation) SetUsername(s string) { m.username = &s } // Username returns the value of the "username" field in the mutation. func (m *UsersMutation) Username() (r string, exists bool) { v := m.username if v == nil { return } return *v, true } // OldUsername returns the old "username" field's value of the Users entity. // If the Users object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UsersMutation) OldUsername(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUsername is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldUsername requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldUsername: %w", err) } return oldValue.Username, nil } // ResetUsername resets all changes to the "username" field. func (m *UsersMutation) ResetUsername() { m.username = nil } // SetPasswordHash sets the "password_hash" field. func (m *UsersMutation) SetPasswordHash(s string) { m.password_hash = &s } // PasswordHash returns the value of the "password_hash" field in the mutation. func (m *UsersMutation) PasswordHash() (r string, exists bool) { v := m.password_hash if v == nil { return } return *v, true } // OldPasswordHash returns the old "password_hash" field's value of the Users entity. // If the Users object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UsersMutation) OldPasswordHash(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldPasswordHash is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldPasswordHash requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldPasswordHash: %w", err) } return oldValue.PasswordHash, nil } // ResetPasswordHash resets all changes to the "password_hash" field. func (m *UsersMutation) ResetPasswordHash() { m.password_hash = nil } // SetEmail sets the "email" field. func (m *UsersMutation) SetEmail(s string) { m.email = &s } // Email returns the value of the "email" field in the mutation. func (m *UsersMutation) Email() (r string, exists bool) { v := m.email if v == nil { return } return *v, true } // OldEmail returns the old "email" field's value of the Users entity. // If the Users object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UsersMutation) OldEmail(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldEmail is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldEmail requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldEmail: %w", err) } return oldValue.Email, nil } // ResetEmail resets all changes to the "email" field. func (m *UsersMutation) ResetEmail() { m.email = nil } // SetPhone sets the "phone" field. func (m *UsersMutation) SetPhone(s string) { m.phone = &s } // Phone returns the value of the "phone" field in the mutation. func (m *UsersMutation) Phone() (r string, exists bool) { v := m.phone if v == nil { return } return *v, true } // OldPhone returns the old "phone" field's value of the Users entity. // If the Users object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UsersMutation) OldPhone(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldPhone is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldPhone requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldPhone: %w", err) } return oldValue.Phone, nil } // ResetPhone resets all changes to the "phone" field. func (m *UsersMutation) ResetPhone() { m.phone = nil } // SetNickname sets the "nickname" field. func (m *UsersMutation) SetNickname(s string) { m.nickname = &s } // Nickname returns the value of the "nickname" field in the mutation. func (m *UsersMutation) Nickname() (r string, exists bool) { v := m.nickname if v == nil { return } return *v, true } // OldNickname returns the old "nickname" field's value of the Users entity. // If the Users object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UsersMutation) OldNickname(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldNickname is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldNickname requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldNickname: %w", err) } return oldValue.Nickname, nil } // ResetNickname resets all changes to the "nickname" field. func (m *UsersMutation) ResetNickname() { m.nickname = nil } // SetAvatar sets the "avatar" field. func (m *UsersMutation) SetAvatar(s string) { m.avatar = &s } // Avatar returns the value of the "avatar" field in the mutation. func (m *UsersMutation) Avatar() (r string, exists bool) { v := m.avatar if v == nil { return } return *v, true } // OldAvatar returns the old "avatar" field's value of the Users entity. // If the Users object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UsersMutation) OldAvatar(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldAvatar is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldAvatar requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldAvatar: %w", err) } return oldValue.Avatar, nil } // ResetAvatar resets all changes to the "avatar" field. func (m *UsersMutation) ResetAvatar() { m.avatar = nil } // SetBio sets the "bio" field. func (m *UsersMutation) SetBio(s string) { m.bio = &s } // Bio returns the value of the "bio" field in the mutation. func (m *UsersMutation) Bio() (r string, exists bool) { v := m.bio if v == nil { return } return *v, true } // OldBio returns the old "bio" field's value of the Users entity. // If the Users object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UsersMutation) OldBio(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldBio is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldBio requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldBio: %w", err) } return oldValue.Bio, nil } // ResetBio resets all changes to the "bio" field. func (m *UsersMutation) ResetBio() { m.bio = nil } // SetCurrentRole sets the "current_role" field. func (m *UsersMutation) SetCurrentRole(s string) { m.current_role = &s } // CurrentRole returns the value of the "current_role" field in the mutation. func (m *UsersMutation) CurrentRole() (r string, exists bool) { v := m.current_role if v == nil { return } return *v, true } // OldCurrentRole returns the old "current_role" field's value of the Users entity. // If the Users object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UsersMutation) OldCurrentRole(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCurrentRole is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldCurrentRole requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldCurrentRole: %w", err) } return oldValue.CurrentRole, nil } // ResetCurrentRole resets all changes to the "current_role" field. func (m *UsersMutation) ResetCurrentRole() { m.current_role = nil } // SetVerifiedRoles sets the "verified_roles" field. func (m *UsersMutation) SetVerifiedRoles(s []string) { m.verified_roles = &s m.appendverified_roles = nil } // VerifiedRoles returns the value of the "verified_roles" field in the mutation. func (m *UsersMutation) VerifiedRoles() (r []string, exists bool) { v := m.verified_roles if v == nil { return } return *v, true } // OldVerifiedRoles returns the old "verified_roles" field's value of the Users entity. // If the Users object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UsersMutation) OldVerifiedRoles(ctx context.Context) (v []string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldVerifiedRoles is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldVerifiedRoles requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldVerifiedRoles: %w", err) } return oldValue.VerifiedRoles, nil } // AppendVerifiedRoles adds s to the "verified_roles" field. func (m *UsersMutation) AppendVerifiedRoles(s []string) { m.appendverified_roles = append(m.appendverified_roles, s...) } // AppendedVerifiedRoles returns the list of values that were appended to the "verified_roles" field in this mutation. func (m *UsersMutation) AppendedVerifiedRoles() ([]string, bool) { if len(m.appendverified_roles) == 0 { return nil, false } return m.appendverified_roles, true } // ResetVerifiedRoles resets all changes to the "verified_roles" field. func (m *UsersMutation) ResetVerifiedRoles() { m.verified_roles = nil m.appendverified_roles = nil } // SetVerificationStatus sets the "verificationStatus" field. func (m *UsersMutation) SetVerificationStatus(sss schema.VerificationStatusStruct) { m.verificationStatus = &sss } // VerificationStatus returns the value of the "verificationStatus" field in the mutation. func (m *UsersMutation) VerificationStatus() (r schema.VerificationStatusStruct, exists bool) { v := m.verificationStatus if v == nil { return } return *v, true } // OldVerificationStatus returns the old "verificationStatus" field's value of the Users entity. // If the Users object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UsersMutation) OldVerificationStatus(ctx context.Context) (v schema.VerificationStatusStruct, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldVerificationStatus is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldVerificationStatus requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldVerificationStatus: %w", err) } return oldValue.VerificationStatus, nil } // ResetVerificationStatus resets all changes to the "verificationStatus" field. func (m *UsersMutation) ResetVerificationStatus() { m.verificationStatus = nil } // SetIsAdmin sets the "is_admin" field. func (m *UsersMutation) SetIsAdmin(b bool) { m.is_admin = &b } // IsAdmin returns the value of the "is_admin" field in the mutation. func (m *UsersMutation) IsAdmin() (r bool, exists bool) { v := m.is_admin if v == nil { return } return *v, true } // OldIsAdmin returns the old "is_admin" field's value of the Users entity. // If the Users object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UsersMutation) OldIsAdmin(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldIsAdmin is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldIsAdmin requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldIsAdmin: %w", err) } return oldValue.IsAdmin, nil } // ResetIsAdmin resets all changes to the "is_admin" field. func (m *UsersMutation) ResetIsAdmin() { m.is_admin = nil } // SetCreatedAt sets the "created_at" field. func (m *UsersMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. func (m *UsersMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return } return *v, true } // OldCreatedAt returns the old "created_at" field's value of the Users entity. // If the Users object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UsersMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldCreatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) } return oldValue.CreatedAt, nil } // ResetCreatedAt resets all changes to the "created_at" field. func (m *UsersMutation) ResetCreatedAt() { m.created_at = nil } // SetUpdatedAt sets the "updated_at" field. func (m *UsersMutation) SetUpdatedAt(t time.Time) { m.updated_at = &t } // UpdatedAt returns the value of the "updated_at" field in the mutation. func (m *UsersMutation) UpdatedAt() (r time.Time, exists bool) { v := m.updated_at if v == nil { return } return *v, true } // OldUpdatedAt returns the old "updated_at" field's value of the Users entity. // If the Users object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UsersMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldUpdatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) } return oldValue.UpdatedAt, nil } // ResetUpdatedAt resets all changes to the "updated_at" field. func (m *UsersMutation) ResetUpdatedAt() { m.updated_at = nil } // SetDeletedAt sets the "deleted_at" field. func (m *UsersMutation) SetDeletedAt(t time.Time) { m.deleted_at = &t } // DeletedAt returns the value of the "deleted_at" field in the mutation. func (m *UsersMutation) DeletedAt() (r time.Time, exists bool) { v := m.deleted_at if v == nil { return } return *v, true } // OldDeletedAt returns the old "deleted_at" field's value of the Users entity. // If the Users object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UsersMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldDeletedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) } return oldValue.DeletedAt, nil } // ResetDeletedAt resets all changes to the "deleted_at" field. func (m *UsersMutation) ResetDeletedAt() { m.deleted_at = nil } // Where appends a list predicates to the UsersMutation builder. func (m *UsersMutation) Where(ps ...predicate.Users) { m.predicates = append(m.predicates, ps...) } // WhereP appends storage-level predicates to the UsersMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. func (m *UsersMutation) WhereP(ps ...func(*sql.Selector)) { p := make([]predicate.Users, len(ps)) for i := range ps { p[i] = ps[i] } m.Where(p...) } // Op returns the operation name. func (m *UsersMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. func (m *UsersMutation) SetOp(op Op) { m.op = op } // Type returns the node type of this mutation (Users). func (m *UsersMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *UsersMutation) Fields() []string { fields := make([]string, 0, 14) if m.username != nil { fields = append(fields, users.FieldUsername) } if m.password_hash != nil { fields = append(fields, users.FieldPasswordHash) } if m.email != nil { fields = append(fields, users.FieldEmail) } if m.phone != nil { fields = append(fields, users.FieldPhone) } if m.nickname != nil { fields = append(fields, users.FieldNickname) } if m.avatar != nil { fields = append(fields, users.FieldAvatar) } if m.bio != nil { fields = append(fields, users.FieldBio) } if m.current_role != nil { fields = append(fields, users.FieldCurrentRole) } if m.verified_roles != nil { fields = append(fields, users.FieldVerifiedRoles) } if m.verificationStatus != nil { fields = append(fields, users.FieldVerificationStatus) } if m.is_admin != nil { fields = append(fields, users.FieldIsAdmin) } if m.created_at != nil { fields = append(fields, users.FieldCreatedAt) } if m.updated_at != nil { fields = append(fields, users.FieldUpdatedAt) } if m.deleted_at != nil { fields = append(fields, users.FieldDeletedAt) } return fields } // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. func (m *UsersMutation) Field(name string) (ent.Value, bool) { switch name { case users.FieldUsername: return m.Username() case users.FieldPasswordHash: return m.PasswordHash() case users.FieldEmail: return m.Email() case users.FieldPhone: return m.Phone() case users.FieldNickname: return m.Nickname() case users.FieldAvatar: return m.Avatar() case users.FieldBio: return m.Bio() case users.FieldCurrentRole: return m.CurrentRole() case users.FieldVerifiedRoles: return m.VerifiedRoles() case users.FieldVerificationStatus: return m.VerificationStatus() case users.FieldIsAdmin: return m.IsAdmin() case users.FieldCreatedAt: return m.CreatedAt() case users.FieldUpdatedAt: return m.UpdatedAt() case users.FieldDeletedAt: return m.DeletedAt() } return nil, false } // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. func (m *UsersMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { case users.FieldUsername: return m.OldUsername(ctx) case users.FieldPasswordHash: return m.OldPasswordHash(ctx) case users.FieldEmail: return m.OldEmail(ctx) case users.FieldPhone: return m.OldPhone(ctx) case users.FieldNickname: return m.OldNickname(ctx) case users.FieldAvatar: return m.OldAvatar(ctx) case users.FieldBio: return m.OldBio(ctx) case users.FieldCurrentRole: return m.OldCurrentRole(ctx) case users.FieldVerifiedRoles: return m.OldVerifiedRoles(ctx) case users.FieldVerificationStatus: return m.OldVerificationStatus(ctx) case users.FieldIsAdmin: return m.OldIsAdmin(ctx) case users.FieldCreatedAt: return m.OldCreatedAt(ctx) case users.FieldUpdatedAt: return m.OldUpdatedAt(ctx) case users.FieldDeletedAt: return m.OldDeletedAt(ctx) } return nil, fmt.Errorf("unknown Users field %s", name) } // 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. func (m *UsersMutation) SetField(name string, value ent.Value) error { switch name { case users.FieldUsername: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUsername(v) return nil case users.FieldPasswordHash: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetPasswordHash(v) return nil case users.FieldEmail: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetEmail(v) return nil case users.FieldPhone: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetPhone(v) return nil case users.FieldNickname: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetNickname(v) return nil case users.FieldAvatar: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetAvatar(v) return nil case users.FieldBio: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetBio(v) return nil case users.FieldCurrentRole: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCurrentRole(v) return nil case users.FieldVerifiedRoles: v, ok := value.([]string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetVerifiedRoles(v) return nil case users.FieldVerificationStatus: v, ok := value.(schema.VerificationStatusStruct) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetVerificationStatus(v) return nil case users.FieldIsAdmin: v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetIsAdmin(v) return nil case users.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil case users.FieldUpdatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUpdatedAt(v) return nil case users.FieldDeletedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetDeletedAt(v) return nil } return fmt.Errorf("unknown Users field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. func (m *UsersMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. func (m *UsersMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the 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. func (m *UsersMutation) AddField(name string, value ent.Value) error { switch name { } return fmt.Errorf("unknown Users numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. func (m *UsersMutation) ClearedFields() []string { return nil } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. func (m *UsersMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. func (m *UsersMutation) ClearField(name string) error { return fmt.Errorf("unknown Users nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. func (m *UsersMutation) ResetField(name string) error { switch name { case users.FieldUsername: m.ResetUsername() return nil case users.FieldPasswordHash: m.ResetPasswordHash() return nil case users.FieldEmail: m.ResetEmail() return nil case users.FieldPhone: m.ResetPhone() return nil case users.FieldNickname: m.ResetNickname() return nil case users.FieldAvatar: m.ResetAvatar() return nil case users.FieldBio: m.ResetBio() return nil case users.FieldCurrentRole: m.ResetCurrentRole() return nil case users.FieldVerifiedRoles: m.ResetVerifiedRoles() return nil case users.FieldVerificationStatus: m.ResetVerificationStatus() return nil case users.FieldIsAdmin: m.ResetIsAdmin() return nil case users.FieldCreatedAt: m.ResetCreatedAt() return nil case users.FieldUpdatedAt: m.ResetUpdatedAt() return nil case users.FieldDeletedAt: m.ResetDeletedAt() return nil } return fmt.Errorf("unknown Users field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. func (m *UsersMutation) AddedEdges() []string { edges := make([]string, 0, 0) return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. func (m *UsersMutation) AddedIDs(name string) []ent.Value { return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *UsersMutation) RemovedEdges() []string { edges := make([]string, 0, 0) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. func (m *UsersMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *UsersMutation) ClearedEdges() []string { edges := make([]string, 0, 0) return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. func (m *UsersMutation) EdgeCleared(name string) bool { return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. func (m *UsersMutation) ClearEdge(name string) error { return fmt.Errorf("unknown Users unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. func (m *UsersMutation) ResetEdge(name string) error { return fmt.Errorf("unknown Users edge %s", name) }