// Copyright 2019-present Facebook Inc. All rights reserved. // This source code is licensed under the Apache 2.0 license found // in the LICENSE file in the root directory of this source tree. // Code generated by ent, DO NOT EDIT. package user import ( "context" "fmt" "entgo.io/ent" "entgo.io/ent/dialect/gremlin/graph/dsl" "entgo.io/ent/entc/integration/gremlin/ent/predicate" ) // Mutation represents an operation that mutates the User nodes in the graph. type Mutation struct { op ent.Op typ string optional_int *int addoptional_int *int age *int addage *int name *string last *string nickname *string address *string phone *string password *string role *Role employment *Employment _SSOCert *string files_count *int addfiles_count *int clearedFields map[string]struct{} card *string clearedcard bool pets map[string]struct{} removedpets map[string]struct{} clearedpets bool files map[string]struct{} removedfiles map[string]struct{} clearedfiles bool groups map[string]struct{} removedgroups map[string]struct{} clearedgroups bool friends map[string]struct{} removedfriends map[string]struct{} clearedfriends bool followers map[string]struct{} removedfollowers map[string]struct{} clearedfollowers bool following map[string]struct{} removedfollowing map[string]struct{} clearedfollowing bool team *string clearedteam bool spouse *string clearedspouse bool children map[string]struct{} removedchildren map[string]struct{} clearedchildren bool parent *string clearedparent bool predicates []predicate.User } // NewMutation creates a new Mutation for the User entity. func NewMutation(op ent.Op) *Mutation { return &Mutation{ op: op, typ: "User", clearedFields: make(map[string]struct{}), } } // Predicates returns the list of predicates set on the mutation. func (m *Mutation) Predicates() []predicate.User { return m.predicates } // SetOptionalInt sets the "optional_int" field. func (m *Mutation) SetOptionalInt(i int) { m.optional_int = &i m.addoptional_int = nil } // OptionalInt returns the value of the "optional_int" field in the mutation. func (m *Mutation) OptionalInt() (r int, exists bool) { v := m.optional_int if v == nil { return } return *v, true } // AddOptionalInt adds i to the "optional_int" field. func (m *Mutation) AddOptionalInt(i int) { if m.addoptional_int != nil { *m.addoptional_int += i } else { m.addoptional_int = &i } } // AddedOptionalInt returns the value that was added to the "optional_int" field in this mutation. func (m *Mutation) AddedOptionalInt() (r int, exists bool) { v := m.addoptional_int if v == nil { return } return *v, true } // ClearOptionalInt clears the value of the "optional_int" field. func (m *Mutation) ClearOptionalInt() { m.optional_int = nil m.addoptional_int = nil m.clearedFields[FieldOptionalInt] = struct{}{} } // OptionalIntCleared returns if the "optional_int" field was cleared in this mutation. func (m *Mutation) OptionalIntCleared() bool { _, ok := m.clearedFields[FieldOptionalInt] return ok } // ResetOptionalInt resets all changes to the "optional_int" field. func (m *Mutation) ResetOptionalInt() { m.optional_int = nil m.addoptional_int = nil delete(m.clearedFields, FieldOptionalInt) } // SetAge sets the "age" field. func (m *Mutation) SetAge(i int) { m.age = &i m.addage = nil } // Age returns the value of the "age" field in the mutation. func (m *Mutation) Age() (r int, exists bool) { v := m.age if v == nil { return } return *v, true } // AddAge adds i to the "age" field. func (m *Mutation) AddAge(i int) { if m.addage != nil { *m.addage += i } else { m.addage = &i } } // AddedAge returns the value that was added to the "age" field in this mutation. func (m *Mutation) AddedAge() (r int, exists bool) { v := m.addage if v == nil { return } return *v, true } // ResetAge resets all changes to the "age" field. func (m *Mutation) ResetAge() { m.age = nil m.addage = nil } // SetName sets the "name" field. func (m *Mutation) SetName(s string) { m.name = &s } // Name returns the value of the "name" field in the mutation. func (m *Mutation) Name() (r string, exists bool) { v := m.name if v == nil { return } return *v, true } // ResetName resets all changes to the "name" field. func (m *Mutation) ResetName() { m.name = nil } // SetLast sets the "last" field. func (m *Mutation) SetLast(s string) { m.last = &s } // Last returns the value of the "last" field in the mutation. func (m *Mutation) Last() (r string, exists bool) { v := m.last if v == nil { return } return *v, true } // ResetLast resets all changes to the "last" field. func (m *Mutation) ResetLast() { m.last = nil } // SetNickname sets the "nickname" field. func (m *Mutation) SetNickname(s string) { m.nickname = &s } // Nickname returns the value of the "nickname" field in the mutation. func (m *Mutation) Nickname() (r string, exists bool) { v := m.nickname if v == nil { return } return *v, true } // ClearNickname clears the value of the "nickname" field. func (m *Mutation) ClearNickname() { m.nickname = nil m.clearedFields[FieldNickname] = struct{}{} } // NicknameCleared returns if the "nickname" field was cleared in this mutation. func (m *Mutation) NicknameCleared() bool { _, ok := m.clearedFields[FieldNickname] return ok } // ResetNickname resets all changes to the "nickname" field. func (m *Mutation) ResetNickname() { m.nickname = nil delete(m.clearedFields, FieldNickname) } // SetAddress sets the "address" field. func (m *Mutation) SetAddress(s string) { m.address = &s } // Address returns the value of the "address" field in the mutation. func (m *Mutation) Address() (r string, exists bool) { v := m.address if v == nil { return } return *v, true } // ClearAddress clears the value of the "address" field. func (m *Mutation) ClearAddress() { m.address = nil m.clearedFields[FieldAddress] = struct{}{} } // AddressCleared returns if the "address" field was cleared in this mutation. func (m *Mutation) AddressCleared() bool { _, ok := m.clearedFields[FieldAddress] return ok } // ResetAddress resets all changes to the "address" field. func (m *Mutation) ResetAddress() { m.address = nil delete(m.clearedFields, FieldAddress) } // SetPhone sets the "phone" field. func (m *Mutation) SetPhone(s string) { m.phone = &s } // Phone returns the value of the "phone" field in the mutation. func (m *Mutation) Phone() (r string, exists bool) { v := m.phone if v == nil { return } return *v, true } // ClearPhone clears the value of the "phone" field. func (m *Mutation) ClearPhone() { m.phone = nil m.clearedFields[FieldPhone] = struct{}{} } // PhoneCleared returns if the "phone" field was cleared in this mutation. func (m *Mutation) PhoneCleared() bool { _, ok := m.clearedFields[FieldPhone] return ok } // ResetPhone resets all changes to the "phone" field. func (m *Mutation) ResetPhone() { m.phone = nil delete(m.clearedFields, FieldPhone) } // SetPassword sets the "password" field. func (m *Mutation) SetPassword(s string) { m.password = &s } // Password returns the value of the "password" field in the mutation. func (m *Mutation) Password() (r string, exists bool) { v := m.password if v == nil { return } return *v, true } // ClearPassword clears the value of the "password" field. func (m *Mutation) ClearPassword() { m.password = nil m.clearedFields[FieldPassword] = struct{}{} } // PasswordCleared returns if the "password" field was cleared in this mutation. func (m *Mutation) PasswordCleared() bool { _, ok := m.clearedFields[FieldPassword] return ok } // ResetPassword resets all changes to the "password" field. func (m *Mutation) ResetPassword() { m.password = nil delete(m.clearedFields, FieldPassword) } // SetRole sets the "role" field. func (m *Mutation) SetRole(u Role) { m.role = &u } // Role returns the value of the "role" field in the mutation. func (m *Mutation) Role() (r Role, exists bool) { v := m.role if v == nil { return } return *v, true } // ResetRole resets all changes to the "role" field. func (m *Mutation) ResetRole() { m.role = nil } // SetEmployment sets the "employment" field. func (m *Mutation) SetEmployment(u Employment) { m.employment = &u } // Employment returns the value of the "employment" field in the mutation. func (m *Mutation) Employment() (r Employment, exists bool) { v := m.employment if v == nil { return } return *v, true } // ResetEmployment resets all changes to the "employment" field. func (m *Mutation) ResetEmployment() { m.employment = nil } // SetSSOCert sets the "SSOCert" field. func (m *Mutation) SetSSOCert(s string) { m._SSOCert = &s } // SSOCert returns the value of the "SSOCert" field in the mutation. func (m *Mutation) SSOCert() (r string, exists bool) { v := m._SSOCert if v == nil { return } return *v, true } // ClearSSOCert clears the value of the "SSOCert" field. func (m *Mutation) ClearSSOCert() { m._SSOCert = nil m.clearedFields[FieldSSOCert] = struct{}{} } // SSOCertCleared returns if the "SSOCert" field was cleared in this mutation. func (m *Mutation) SSOCertCleared() bool { _, ok := m.clearedFields[FieldSSOCert] return ok } // ResetSSOCert resets all changes to the "SSOCert" field. func (m *Mutation) ResetSSOCert() { m._SSOCert = nil delete(m.clearedFields, FieldSSOCert) } // SetFilesCount sets the "files_count" field. func (m *Mutation) SetFilesCount(i int) { m.files_count = &i m.addfiles_count = nil } // FilesCount returns the value of the "files_count" field in the mutation. func (m *Mutation) FilesCount() (r int, exists bool) { v := m.files_count if v == nil { return } return *v, true } // AddFilesCount adds i to the "files_count" field. func (m *Mutation) AddFilesCount(i int) { if m.addfiles_count != nil { *m.addfiles_count += i } else { m.addfiles_count = &i } } // AddedFilesCount returns the value that was added to the "files_count" field in this mutation. func (m *Mutation) AddedFilesCount() (r int, exists bool) { v := m.addfiles_count if v == nil { return } return *v, true } // ClearFilesCount clears the value of the "files_count" field. func (m *Mutation) ClearFilesCount() { m.files_count = nil m.addfiles_count = nil m.clearedFields[FieldFilesCount] = struct{}{} } // FilesCountCleared returns if the "files_count" field was cleared in this mutation. func (m *Mutation) FilesCountCleared() bool { _, ok := m.clearedFields[FieldFilesCount] return ok } // ResetFilesCount resets all changes to the "files_count" field. func (m *Mutation) ResetFilesCount() { m.files_count = nil m.addfiles_count = nil delete(m.clearedFields, FieldFilesCount) } // SetCardID sets the "card" edge to the Card entity by id. func (m *Mutation) SetCardID(id string) { m.card = &id } // ClearCard clears the "card" edge to the Card entity. func (m *Mutation) ClearCard() { m.clearedcard = true } // CardCleared reports if the "card" edge to the Card entity was cleared. func (m *Mutation) CardCleared() bool { return m.clearedcard } // CardID returns the "card" edge ID in the mutation. func (m *Mutation) CardID() (id string, exists bool) { if m.card != nil { return *m.card, true } return } // CardIDs returns the "card" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // CardID instead. It exists only for internal usage by the builders. func (m *Mutation) CardIDs() (ids []string) { if id := m.card; id != nil { ids = append(ids, *id) } return } // ResetCard resets all changes to the "card" edge. func (m *Mutation) ResetCard() { m.card = nil m.clearedcard = false } // AddPetIDs adds the "pets" edge to the Pet entity by ids. func (m *Mutation) AddPetIDs(ids ...string) { if m.pets == nil { m.pets = make(map[string]struct{}) } for i := range ids { m.pets[ids[i]] = struct{}{} } } // ClearPets clears the "pets" edge to the Pet entity. func (m *Mutation) ClearPets() { m.clearedpets = true } // PetsCleared reports if the "pets" edge to the Pet entity was cleared. func (m *Mutation) PetsCleared() bool { return m.clearedpets } // RemovePetIDs removes the "pets" edge to the Pet entity by IDs. func (m *Mutation) RemovePetIDs(ids ...string) { if m.removedpets == nil { m.removedpets = make(map[string]struct{}) } for i := range ids { delete(m.pets, ids[i]) m.removedpets[ids[i]] = struct{}{} } } // RemovedPets returns the removed IDs of the "pets" edge to the Pet entity. func (m *Mutation) RemovedPetsIDs() (ids []string) { for id := range m.removedpets { ids = append(ids, id) } return } // PetsIDs returns the "pets" edge IDs in the mutation. func (m *Mutation) PetsIDs() (ids []string) { for id := range m.pets { ids = append(ids, id) } return } // ResetPets resets all changes to the "pets" edge. func (m *Mutation) ResetPets() { m.pets = nil m.clearedpets = false m.removedpets = nil } // AddFileIDs adds the "files" edge to the File entity by ids. func (m *Mutation) AddFileIDs(ids ...string) { if m.files == nil { m.files = make(map[string]struct{}) } for i := range ids { m.files[ids[i]] = struct{}{} } } // ClearFiles clears the "files" edge to the File entity. func (m *Mutation) ClearFiles() { m.clearedfiles = true } // FilesCleared reports if the "files" edge to the File entity was cleared. func (m *Mutation) FilesCleared() bool { return m.clearedfiles } // RemoveFileIDs removes the "files" edge to the File entity by IDs. func (m *Mutation) RemoveFileIDs(ids ...string) { if m.removedfiles == nil { m.removedfiles = make(map[string]struct{}) } for i := range ids { delete(m.files, ids[i]) m.removedfiles[ids[i]] = struct{}{} } } // RemovedFiles returns the removed IDs of the "files" edge to the File entity. func (m *Mutation) RemovedFilesIDs() (ids []string) { for id := range m.removedfiles { ids = append(ids, id) } return } // FilesIDs returns the "files" edge IDs in the mutation. func (m *Mutation) FilesIDs() (ids []string) { for id := range m.files { ids = append(ids, id) } return } // ResetFiles resets all changes to the "files" edge. func (m *Mutation) ResetFiles() { m.files = nil m.clearedfiles = false m.removedfiles = nil } // AddGroupIDs adds the "groups" edge to the Group entity by ids. func (m *Mutation) AddGroupIDs(ids ...string) { if m.groups == nil { m.groups = make(map[string]struct{}) } for i := range ids { m.groups[ids[i]] = struct{}{} } } // ClearGroups clears the "groups" edge to the Group entity. func (m *Mutation) ClearGroups() { m.clearedgroups = true } // GroupsCleared reports if the "groups" edge to the Group entity was cleared. func (m *Mutation) GroupsCleared() bool { return m.clearedgroups } // RemoveGroupIDs removes the "groups" edge to the Group entity by IDs. func (m *Mutation) RemoveGroupIDs(ids ...string) { if m.removedgroups == nil { m.removedgroups = make(map[string]struct{}) } for i := range ids { delete(m.groups, ids[i]) m.removedgroups[ids[i]] = struct{}{} } } // RemovedGroups returns the removed IDs of the "groups" edge to the Group entity. func (m *Mutation) RemovedGroupsIDs() (ids []string) { for id := range m.removedgroups { ids = append(ids, id) } return } // GroupsIDs returns the "groups" edge IDs in the mutation. func (m *Mutation) GroupsIDs() (ids []string) { for id := range m.groups { ids = append(ids, id) } return } // ResetGroups resets all changes to the "groups" edge. func (m *Mutation) ResetGroups() { m.groups = nil m.clearedgroups = false m.removedgroups = nil } // AddFriendIDs adds the "friends" edge to the User entity by ids. func (m *Mutation) AddFriendIDs(ids ...string) { if m.friends == nil { m.friends = make(map[string]struct{}) } for i := range ids { m.friends[ids[i]] = struct{}{} } } // ClearFriends clears the "friends" edge to the User entity. func (m *Mutation) ClearFriends() { m.clearedfriends = true } // FriendsCleared reports if the "friends" edge to the User entity was cleared. func (m *Mutation) FriendsCleared() bool { return m.clearedfriends } // RemoveFriendIDs removes the "friends" edge to the User entity by IDs. func (m *Mutation) RemoveFriendIDs(ids ...string) { if m.removedfriends == nil { m.removedfriends = make(map[string]struct{}) } for i := range ids { delete(m.friends, ids[i]) m.removedfriends[ids[i]] = struct{}{} } } // RemovedFriends returns the removed IDs of the "friends" edge to the User entity. func (m *Mutation) RemovedFriendsIDs() (ids []string) { for id := range m.removedfriends { ids = append(ids, id) } return } // FriendsIDs returns the "friends" edge IDs in the mutation. func (m *Mutation) FriendsIDs() (ids []string) { for id := range m.friends { ids = append(ids, id) } return } // ResetFriends resets all changes to the "friends" edge. func (m *Mutation) ResetFriends() { m.friends = nil m.clearedfriends = false m.removedfriends = nil } // AddFollowerIDs adds the "followers" edge to the User entity by ids. func (m *Mutation) AddFollowerIDs(ids ...string) { if m.followers == nil { m.followers = make(map[string]struct{}) } for i := range ids { m.followers[ids[i]] = struct{}{} } } // ClearFollowers clears the "followers" edge to the User entity. func (m *Mutation) ClearFollowers() { m.clearedfollowers = true } // FollowersCleared reports if the "followers" edge to the User entity was cleared. func (m *Mutation) FollowersCleared() bool { return m.clearedfollowers } // RemoveFollowerIDs removes the "followers" edge to the User entity by IDs. func (m *Mutation) RemoveFollowerIDs(ids ...string) { if m.removedfollowers == nil { m.removedfollowers = make(map[string]struct{}) } for i := range ids { delete(m.followers, ids[i]) m.removedfollowers[ids[i]] = struct{}{} } } // RemovedFollowers returns the removed IDs of the "followers" edge to the User entity. func (m *Mutation) RemovedFollowersIDs() (ids []string) { for id := range m.removedfollowers { ids = append(ids, id) } return } // FollowersIDs returns the "followers" edge IDs in the mutation. func (m *Mutation) FollowersIDs() (ids []string) { for id := range m.followers { ids = append(ids, id) } return } // ResetFollowers resets all changes to the "followers" edge. func (m *Mutation) ResetFollowers() { m.followers = nil m.clearedfollowers = false m.removedfollowers = nil } // AddFollowingIDs adds the "following" edge to the User entity by ids. func (m *Mutation) AddFollowingIDs(ids ...string) { if m.following == nil { m.following = make(map[string]struct{}) } for i := range ids { m.following[ids[i]] = struct{}{} } } // ClearFollowing clears the "following" edge to the User entity. func (m *Mutation) ClearFollowing() { m.clearedfollowing = true } // FollowingCleared reports if the "following" edge to the User entity was cleared. func (m *Mutation) FollowingCleared() bool { return m.clearedfollowing } // RemoveFollowingIDs removes the "following" edge to the User entity by IDs. func (m *Mutation) RemoveFollowingIDs(ids ...string) { if m.removedfollowing == nil { m.removedfollowing = make(map[string]struct{}) } for i := range ids { delete(m.following, ids[i]) m.removedfollowing[ids[i]] = struct{}{} } } // RemovedFollowing returns the removed IDs of the "following" edge to the User entity. func (m *Mutation) RemovedFollowingIDs() (ids []string) { for id := range m.removedfollowing { ids = append(ids, id) } return } // FollowingIDs returns the "following" edge IDs in the mutation. func (m *Mutation) FollowingIDs() (ids []string) { for id := range m.following { ids = append(ids, id) } return } // ResetFollowing resets all changes to the "following" edge. func (m *Mutation) ResetFollowing() { m.following = nil m.clearedfollowing = false m.removedfollowing = nil } // SetTeamID sets the "team" edge to the Pet entity by id. func (m *Mutation) SetTeamID(id string) { m.team = &id } // ClearTeam clears the "team" edge to the Pet entity. func (m *Mutation) ClearTeam() { m.clearedteam = true } // TeamCleared reports if the "team" edge to the Pet entity was cleared. func (m *Mutation) TeamCleared() bool { return m.clearedteam } // TeamID returns the "team" edge ID in the mutation. func (m *Mutation) TeamID() (id string, exists bool) { if m.team != nil { return *m.team, true } return } // TeamIDs returns the "team" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // TeamID instead. It exists only for internal usage by the builders. func (m *Mutation) TeamIDs() (ids []string) { if id := m.team; id != nil { ids = append(ids, *id) } return } // ResetTeam resets all changes to the "team" edge. func (m *Mutation) ResetTeam() { m.team = nil m.clearedteam = false } // SetSpouseID sets the "spouse" edge to the User entity by id. func (m *Mutation) SetSpouseID(id string) { m.spouse = &id } // ClearSpouse clears the "spouse" edge to the User entity. func (m *Mutation) ClearSpouse() { m.clearedspouse = true } // SpouseCleared reports if the "spouse" edge to the User entity was cleared. func (m *Mutation) SpouseCleared() bool { return m.clearedspouse } // SpouseID returns the "spouse" edge ID in the mutation. func (m *Mutation) SpouseID() (id string, exists bool) { if m.spouse != nil { return *m.spouse, true } return } // SpouseIDs returns the "spouse" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // SpouseID instead. It exists only for internal usage by the builders. func (m *Mutation) SpouseIDs() (ids []string) { if id := m.spouse; id != nil { ids = append(ids, *id) } return } // ResetSpouse resets all changes to the "spouse" edge. func (m *Mutation) ResetSpouse() { m.spouse = nil m.clearedspouse = false } // AddChildIDs adds the "children" edge to the User entity by ids. func (m *Mutation) AddChildIDs(ids ...string) { if m.children == nil { m.children = make(map[string]struct{}) } for i := range ids { m.children[ids[i]] = struct{}{} } } // ClearChildren clears the "children" edge to the User entity. func (m *Mutation) ClearChildren() { m.clearedchildren = true } // ChildrenCleared reports if the "children" edge to the User entity was cleared. func (m *Mutation) ChildrenCleared() bool { return m.clearedchildren } // RemoveChildIDs removes the "children" edge to the User entity by IDs. func (m *Mutation) RemoveChildIDs(ids ...string) { if m.removedchildren == nil { m.removedchildren = make(map[string]struct{}) } for i := range ids { delete(m.children, ids[i]) m.removedchildren[ids[i]] = struct{}{} } } // RemovedChildren returns the removed IDs of the "children" edge to the User entity. func (m *Mutation) RemovedChildrenIDs() (ids []string) { for id := range m.removedchildren { ids = append(ids, id) } return } // ChildrenIDs returns the "children" edge IDs in the mutation. func (m *Mutation) ChildrenIDs() (ids []string) { for id := range m.children { ids = append(ids, id) } return } // ResetChildren resets all changes to the "children" edge. func (m *Mutation) ResetChildren() { m.children = nil m.clearedchildren = false m.removedchildren = nil } // SetParentID sets the "parent" edge to the User entity by id. func (m *Mutation) SetParentID(id string) { m.parent = &id } // ClearParent clears the "parent" edge to the User entity. func (m *Mutation) ClearParent() { m.clearedparent = true } // ParentCleared reports if the "parent" edge to the User entity was cleared. func (m *Mutation) ParentCleared() bool { return m.clearedparent } // ParentID returns the "parent" edge ID in the mutation. func (m *Mutation) ParentID() (id string, exists bool) { if m.parent != nil { return *m.parent, true } return } // ParentIDs returns the "parent" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // ParentID instead. It exists only for internal usage by the builders. func (m *Mutation) ParentIDs() (ids []string) { if id := m.parent; id != nil { ids = append(ids, *id) } return } // ResetParent resets all changes to the "parent" edge. func (m *Mutation) ResetParent() { m.parent = nil m.clearedparent = false } // Where appends a list predicates to the Mutation builder. func (m *Mutation) Where(ps ...predicate.User) { m.predicates = append(m.predicates, ps...) } // WhereP appends storage-level predicates to the Mutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. func (m *Mutation) WhereP(ps ...func(*dsl.Traversal)) { p := make([]predicate.User, len(ps)) for i := range ps { p[i] = ps[i] } m.Where(p...) } // Op returns the operation name. func (m *Mutation) Op() ent.Op { return m.op } // SetOp allows setting the mutation operation. func (m *Mutation) SetOp(op ent.Op) { m.op = op } // Type returns the node type of this mutation (User). func (m *Mutation) 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 *Mutation) Fields() []string { fields := make([]string, 0, 12) if m.optional_int != nil { fields = append(fields, FieldOptionalInt) } if m.age != nil { fields = append(fields, FieldAge) } if m.name != nil { fields = append(fields, FieldName) } if m.last != nil { fields = append(fields, FieldLast) } if m.nickname != nil { fields = append(fields, FieldNickname) } if m.address != nil { fields = append(fields, FieldAddress) } if m.phone != nil { fields = append(fields, FieldPhone) } if m.password != nil { fields = append(fields, FieldPassword) } if m.role != nil { fields = append(fields, FieldRole) } if m.employment != nil { fields = append(fields, FieldEmployment) } if m._SSOCert != nil { fields = append(fields, FieldSSOCert) } if m.files_count != nil { fields = append(fields, FieldFilesCount) } 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 *Mutation) Field(name string) (ent.Value, bool) { switch name { case FieldOptionalInt: return m.OptionalInt() case FieldAge: return m.Age() case FieldName: return m.Name() case FieldLast: return m.Last() case FieldNickname: return m.Nickname() case FieldAddress: return m.Address() case FieldPhone: return m.Phone() case FieldPassword: return m.Password() case FieldRole: return m.Role() case FieldEmployment: return m.Employment() case FieldSSOCert: return m.SSOCert() case FieldFilesCount: return m.FilesCount() } 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 *Mutation) OldField(ctx context.Context, name string) (ent.Value, error) { return nil, fmt.Errorf("unknown User 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 *Mutation) SetField(name string, value ent.Value) error { switch name { case FieldOptionalInt: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetOptionalInt(v) return nil case FieldAge: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetAge(v) return nil case FieldName: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetName(v) return nil case FieldLast: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetLast(v) return nil case FieldNickname: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetNickname(v) return nil case FieldAddress: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetAddress(v) return nil case FieldPhone: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetPhone(v) return nil case FieldPassword: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetPassword(v) return nil case FieldRole: v, ok := value.(Role) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetRole(v) return nil case FieldEmployment: v, ok := value.(Employment) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetEmployment(v) return nil case FieldSSOCert: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetSSOCert(v) return nil case FieldFilesCount: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetFilesCount(v) return nil } return fmt.Errorf("unknown User field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. func (m *Mutation) AddedFields() []string { var fields []string if m.addoptional_int != nil { fields = append(fields, FieldOptionalInt) } if m.addage != nil { fields = append(fields, FieldAge) } if m.addfiles_count != nil { fields = append(fields, FieldFilesCount) } return fields } // 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 *Mutation) AddedField(name string) (ent.Value, bool) { switch name { case FieldOptionalInt: return m.AddedOptionalInt() case FieldAge: return m.AddedAge() case FieldFilesCount: return m.AddedFilesCount() } 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 *Mutation) AddField(name string, value ent.Value) error { switch name { case FieldOptionalInt: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddOptionalInt(v) return nil case FieldAge: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddAge(v) return nil case FieldFilesCount: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddFilesCount(v) return nil } return fmt.Errorf("unknown User numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. func (m *Mutation) ClearedFields() []string { var fields []string if m.FieldCleared(FieldOptionalInt) { fields = append(fields, FieldOptionalInt) } if m.FieldCleared(FieldNickname) { fields = append(fields, FieldNickname) } if m.FieldCleared(FieldAddress) { fields = append(fields, FieldAddress) } if m.FieldCleared(FieldPhone) { fields = append(fields, FieldPhone) } if m.FieldCleared(FieldPassword) { fields = append(fields, FieldPassword) } if m.FieldCleared(FieldSSOCert) { fields = append(fields, FieldSSOCert) } if m.FieldCleared(FieldFilesCount) { fields = append(fields, FieldFilesCount) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. func (m *Mutation) 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 *Mutation) ClearField(name string) error { switch name { case FieldOptionalInt: m.ClearOptionalInt() return nil case FieldNickname: m.ClearNickname() return nil case FieldAddress: m.ClearAddress() return nil case FieldPhone: m.ClearPhone() return nil case FieldPassword: m.ClearPassword() return nil case FieldSSOCert: m.ClearSSOCert() return nil case FieldFilesCount: m.ClearFilesCount() return nil } return fmt.Errorf("unknown User 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 *Mutation) ResetField(name string) error { switch name { case FieldOptionalInt: m.ResetOptionalInt() return nil case FieldAge: m.ResetAge() return nil case FieldName: m.ResetName() return nil case FieldLast: m.ResetLast() return nil case FieldNickname: m.ResetNickname() return nil case FieldAddress: m.ResetAddress() return nil case FieldPhone: m.ResetPhone() return nil case FieldPassword: m.ResetPassword() return nil case FieldRole: m.ResetRole() return nil case FieldEmployment: m.ResetEmployment() return nil case FieldSSOCert: m.ResetSSOCert() return nil case FieldFilesCount: m.ResetFilesCount() return nil } return fmt.Errorf("unknown User field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. func (m *Mutation) AddedEdges() []string { edges := make([]string, 0, 11) if m.card != nil { edges = append(edges, EdgeCard) } if m.pets != nil { edges = append(edges, EdgePets) } if m.files != nil { edges = append(edges, EdgeFiles) } if m.groups != nil { edges = append(edges, EdgeGroups) } if m.friends != nil { edges = append(edges, EdgeFriends) } if m.followers != nil { edges = append(edges, EdgeFollowers) } if m.following != nil { edges = append(edges, EdgeFollowing) } if m.team != nil { edges = append(edges, EdgeTeam) } if m.spouse != nil { edges = append(edges, EdgeSpouse) } if m.children != nil { edges = append(edges, EdgeChildren) } if m.parent != nil { edges = append(edges, EdgeParent) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. func (m *Mutation) AddedIDs(name string) []ent.Value { switch name { case EdgeCard: if id := m.card; id != nil { return []ent.Value{*id} } case EdgePets: ids := make([]ent.Value, 0, len(m.pets)) for id := range m.pets { ids = append(ids, id) } return ids case EdgeFiles: ids := make([]ent.Value, 0, len(m.files)) for id := range m.files { ids = append(ids, id) } return ids case EdgeGroups: ids := make([]ent.Value, 0, len(m.groups)) for id := range m.groups { ids = append(ids, id) } return ids case EdgeFriends: ids := make([]ent.Value, 0, len(m.friends)) for id := range m.friends { ids = append(ids, id) } return ids case EdgeFollowers: ids := make([]ent.Value, 0, len(m.followers)) for id := range m.followers { ids = append(ids, id) } return ids case EdgeFollowing: ids := make([]ent.Value, 0, len(m.following)) for id := range m.following { ids = append(ids, id) } return ids case EdgeTeam: if id := m.team; id != nil { return []ent.Value{*id} } case EdgeSpouse: if id := m.spouse; id != nil { return []ent.Value{*id} } case EdgeChildren: ids := make([]ent.Value, 0, len(m.children)) for id := range m.children { ids = append(ids, id) } return ids case EdgeParent: if id := m.parent; id != nil { return []ent.Value{*id} } } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *Mutation) RemovedEdges() []string { edges := make([]string, 0, 11) if m.removedpets != nil { edges = append(edges, EdgePets) } if m.removedfiles != nil { edges = append(edges, EdgeFiles) } if m.removedgroups != nil { edges = append(edges, EdgeGroups) } if m.removedfriends != nil { edges = append(edges, EdgeFriends) } if m.removedfollowers != nil { edges = append(edges, EdgeFollowers) } if m.removedfollowing != nil { edges = append(edges, EdgeFollowing) } if m.removedchildren != nil { edges = append(edges, EdgeChildren) } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. func (m *Mutation) RemovedIDs(name string) []ent.Value { switch name { case EdgePets: ids := make([]ent.Value, 0, len(m.removedpets)) for id := range m.removedpets { ids = append(ids, id) } return ids case EdgeFiles: ids := make([]ent.Value, 0, len(m.removedfiles)) for id := range m.removedfiles { ids = append(ids, id) } return ids case EdgeGroups: ids := make([]ent.Value, 0, len(m.removedgroups)) for id := range m.removedgroups { ids = append(ids, id) } return ids case EdgeFriends: ids := make([]ent.Value, 0, len(m.removedfriends)) for id := range m.removedfriends { ids = append(ids, id) } return ids case EdgeFollowers: ids := make([]ent.Value, 0, len(m.removedfollowers)) for id := range m.removedfollowers { ids = append(ids, id) } return ids case EdgeFollowing: ids := make([]ent.Value, 0, len(m.removedfollowing)) for id := range m.removedfollowing { ids = append(ids, id) } return ids case EdgeChildren: ids := make([]ent.Value, 0, len(m.removedchildren)) for id := range m.removedchildren { ids = append(ids, id) } return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *Mutation) ClearedEdges() []string { edges := make([]string, 0, 11) if m.clearedcard { edges = append(edges, EdgeCard) } if m.clearedpets { edges = append(edges, EdgePets) } if m.clearedfiles { edges = append(edges, EdgeFiles) } if m.clearedgroups { edges = append(edges, EdgeGroups) } if m.clearedfriends { edges = append(edges, EdgeFriends) } if m.clearedfollowers { edges = append(edges, EdgeFollowers) } if m.clearedfollowing { edges = append(edges, EdgeFollowing) } if m.clearedteam { edges = append(edges, EdgeTeam) } if m.clearedspouse { edges = append(edges, EdgeSpouse) } if m.clearedchildren { edges = append(edges, EdgeChildren) } if m.clearedparent { edges = append(edges, EdgeParent) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. func (m *Mutation) EdgeCleared(name string) bool { switch name { case EdgeCard: return m.clearedcard case EdgePets: return m.clearedpets case EdgeFiles: return m.clearedfiles case EdgeGroups: return m.clearedgroups case EdgeFriends: return m.clearedfriends case EdgeFollowers: return m.clearedfollowers case EdgeFollowing: return m.clearedfollowing case EdgeTeam: return m.clearedteam case EdgeSpouse: return m.clearedspouse case EdgeChildren: return m.clearedchildren case EdgeParent: return m.clearedparent } 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 *Mutation) ClearEdge(name string) error { switch name { case EdgeCard: m.ClearCard() return nil case EdgeTeam: m.ClearTeam() return nil case EdgeSpouse: m.ClearSpouse() return nil case EdgeParent: m.ClearParent() return nil } return fmt.Errorf("unknown User 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 *Mutation) ResetEdge(name string) error { switch name { case EdgeCard: m.ResetCard() return nil case EdgePets: m.ResetPets() return nil case EdgeFiles: m.ResetFiles() return nil case EdgeGroups: m.ResetGroups() return nil case EdgeFriends: m.ResetFriends() return nil case EdgeFollowers: m.ResetFollowers() return nil case EdgeFollowing: m.ResetFollowing() return nil case EdgeTeam: m.ResetTeam() return nil case EdgeSpouse: m.ResetSpouse() return nil case EdgeChildren: m.ResetChildren() return nil case EdgeParent: m.ResetParent() return nil } return fmt.Errorf("unknown User edge %s", name) }