1796 lines
51 KiB
Go
1796 lines
51 KiB
Go
// 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 ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/gremlin"
|
|
"entgo.io/ent/dialect/gremlin/graph/dsl"
|
|
"entgo.io/ent/dialect/gremlin/graph/dsl/__"
|
|
"entgo.io/ent/dialect/gremlin/graph/dsl/g"
|
|
"entgo.io/ent/dialect/gremlin/graph/dsl/p"
|
|
"entgo.io/ent/entc/integration/gremlin/ent/predicate"
|
|
"entgo.io/ent/entc/integration/gremlin/ent/user"
|
|
)
|
|
|
|
// UserUpdate is the builder for updating User entities.
|
|
type UserUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *UserMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the UserUpdate builder.
|
|
func (_u *UserUpdate) Where(ps ...predicate.User) *UserUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetOptionalInt sets the "optional_int" field.
|
|
func (_u *UserUpdate) SetOptionalInt(v int) *UserUpdate {
|
|
_u.mutation.ResetOptionalInt()
|
|
_u.mutation.SetOptionalInt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOptionalInt sets the "optional_int" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableOptionalInt(v *int) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetOptionalInt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddOptionalInt adds value to the "optional_int" field.
|
|
func (_u *UserUpdate) AddOptionalInt(v int) *UserUpdate {
|
|
_u.mutation.AddOptionalInt(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearOptionalInt clears the value of the "optional_int" field.
|
|
func (_u *UserUpdate) ClearOptionalInt() *UserUpdate {
|
|
_u.mutation.ClearOptionalInt()
|
|
return _u
|
|
}
|
|
|
|
// SetAge sets the "age" field.
|
|
func (_u *UserUpdate) SetAge(v int) *UserUpdate {
|
|
_u.mutation.ResetAge()
|
|
_u.mutation.SetAge(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAge sets the "age" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableAge(v *int) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetAge(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddAge adds value to the "age" field.
|
|
func (_u *UserUpdate) AddAge(v int) *UserUpdate {
|
|
_u.mutation.AddAge(v)
|
|
return _u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_u *UserUpdate) SetName(v string) *UserUpdate {
|
|
_u.mutation.SetName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableName(v *string) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetLast sets the "last" field.
|
|
func (_u *UserUpdate) SetLast(v string) *UserUpdate {
|
|
_u.mutation.SetLast(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLast sets the "last" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableLast(v *string) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetLast(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetNickname sets the "nickname" field.
|
|
func (_u *UserUpdate) SetNickname(v string) *UserUpdate {
|
|
_u.mutation.SetNickname(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableNickname sets the "nickname" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableNickname(v *string) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetNickname(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearNickname clears the value of the "nickname" field.
|
|
func (_u *UserUpdate) ClearNickname() *UserUpdate {
|
|
_u.mutation.ClearNickname()
|
|
return _u
|
|
}
|
|
|
|
// SetAddress sets the "address" field.
|
|
func (_u *UserUpdate) SetAddress(v string) *UserUpdate {
|
|
_u.mutation.SetAddress(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAddress sets the "address" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableAddress(v *string) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetAddress(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearAddress clears the value of the "address" field.
|
|
func (_u *UserUpdate) ClearAddress() *UserUpdate {
|
|
_u.mutation.ClearAddress()
|
|
return _u
|
|
}
|
|
|
|
// SetPhone sets the "phone" field.
|
|
func (_u *UserUpdate) SetPhone(v string) *UserUpdate {
|
|
_u.mutation.SetPhone(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePhone sets the "phone" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillablePhone(v *string) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetPhone(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearPhone clears the value of the "phone" field.
|
|
func (_u *UserUpdate) ClearPhone() *UserUpdate {
|
|
_u.mutation.ClearPhone()
|
|
return _u
|
|
}
|
|
|
|
// SetPassword sets the "password" field.
|
|
func (_u *UserUpdate) SetPassword(v string) *UserUpdate {
|
|
_u.mutation.SetPassword(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePassword sets the "password" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillablePassword(v *string) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetPassword(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearPassword clears the value of the "password" field.
|
|
func (_u *UserUpdate) ClearPassword() *UserUpdate {
|
|
_u.mutation.ClearPassword()
|
|
return _u
|
|
}
|
|
|
|
// SetRole sets the "role" field.
|
|
func (_u *UserUpdate) SetRole(v user.Role) *UserUpdate {
|
|
_u.mutation.SetRole(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRole sets the "role" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableRole(v *user.Role) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetRole(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetEmployment sets the "employment" field.
|
|
func (_u *UserUpdate) SetEmployment(v user.Employment) *UserUpdate {
|
|
_u.mutation.SetEmployment(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEmployment sets the "employment" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableEmployment(v *user.Employment) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetEmployment(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSSOCert sets the "SSOCert" field.
|
|
func (_u *UserUpdate) SetSSOCert(v string) *UserUpdate {
|
|
_u.mutation.SetSSOCert(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSSOCert sets the "SSOCert" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableSSOCert(v *string) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetSSOCert(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSSOCert clears the value of the "SSOCert" field.
|
|
func (_u *UserUpdate) ClearSSOCert() *UserUpdate {
|
|
_u.mutation.ClearSSOCert()
|
|
return _u
|
|
}
|
|
|
|
// SetFilesCount sets the "files_count" field.
|
|
func (_u *UserUpdate) SetFilesCount(v int) *UserUpdate {
|
|
_u.mutation.ResetFilesCount()
|
|
_u.mutation.SetFilesCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableFilesCount sets the "files_count" field if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableFilesCount(v *int) *UserUpdate {
|
|
if v != nil {
|
|
_u.SetFilesCount(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddFilesCount adds value to the "files_count" field.
|
|
func (_u *UserUpdate) AddFilesCount(v int) *UserUpdate {
|
|
_u.mutation.AddFilesCount(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearFilesCount clears the value of the "files_count" field.
|
|
func (_u *UserUpdate) ClearFilesCount() *UserUpdate {
|
|
_u.mutation.ClearFilesCount()
|
|
return _u
|
|
}
|
|
|
|
// SetCardID sets the "card" edge to the Card entity by ID.
|
|
func (_u *UserUpdate) SetCardID(id string) *UserUpdate {
|
|
_u.mutation.SetCardID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCardID sets the "card" edge to the Card entity by ID if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableCardID(id *string) *UserUpdate {
|
|
if id != nil {
|
|
_u = _u.SetCardID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCard sets the "card" edge to the Card entity.
|
|
func (_u *UserUpdate) SetCard(v *Card) *UserUpdate {
|
|
return _u.SetCardID(v.ID)
|
|
}
|
|
|
|
// AddPetIDs adds the "pets" edge to the Pet entity by IDs.
|
|
func (_u *UserUpdate) AddPetIDs(ids ...string) *UserUpdate {
|
|
_u.mutation.AddPetIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddPets adds the "pets" edges to the Pet entity.
|
|
func (_u *UserUpdate) AddPets(v ...*Pet) *UserUpdate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddPetIDs(ids...)
|
|
}
|
|
|
|
// AddFileIDs adds the "files" edge to the File entity by IDs.
|
|
func (_u *UserUpdate) AddFileIDs(ids ...string) *UserUpdate {
|
|
_u.mutation.AddFileIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddFiles adds the "files" edges to the File entity.
|
|
func (_u *UserUpdate) AddFiles(v ...*File) *UserUpdate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddFileIDs(ids...)
|
|
}
|
|
|
|
// AddGroupIDs adds the "groups" edge to the Group entity by IDs.
|
|
func (_u *UserUpdate) AddGroupIDs(ids ...string) *UserUpdate {
|
|
_u.mutation.AddGroupIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddGroups adds the "groups" edges to the Group entity.
|
|
func (_u *UserUpdate) AddGroups(v ...*Group) *UserUpdate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddGroupIDs(ids...)
|
|
}
|
|
|
|
// AddFriendIDs adds the "friends" edge to the User entity by IDs.
|
|
func (_u *UserUpdate) AddFriendIDs(ids ...string) *UserUpdate {
|
|
_u.mutation.AddFriendIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddFriends adds the "friends" edges to the User entity.
|
|
func (_u *UserUpdate) AddFriends(v ...*User) *UserUpdate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddFriendIDs(ids...)
|
|
}
|
|
|
|
// AddFollowerIDs adds the "followers" edge to the User entity by IDs.
|
|
func (_u *UserUpdate) AddFollowerIDs(ids ...string) *UserUpdate {
|
|
_u.mutation.AddFollowerIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddFollowers adds the "followers" edges to the User entity.
|
|
func (_u *UserUpdate) AddFollowers(v ...*User) *UserUpdate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddFollowerIDs(ids...)
|
|
}
|
|
|
|
// AddFollowingIDs adds the "following" edge to the User entity by IDs.
|
|
func (_u *UserUpdate) AddFollowingIDs(ids ...string) *UserUpdate {
|
|
_u.mutation.AddFollowingIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddFollowing adds the "following" edges to the User entity.
|
|
func (_u *UserUpdate) AddFollowing(v ...*User) *UserUpdate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddFollowingIDs(ids...)
|
|
}
|
|
|
|
// SetTeamID sets the "team" edge to the Pet entity by ID.
|
|
func (_u *UserUpdate) SetTeamID(id string) *UserUpdate {
|
|
_u.mutation.SetTeamID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTeamID sets the "team" edge to the Pet entity by ID if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableTeamID(id *string) *UserUpdate {
|
|
if id != nil {
|
|
_u = _u.SetTeamID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetTeam sets the "team" edge to the Pet entity.
|
|
func (_u *UserUpdate) SetTeam(v *Pet) *UserUpdate {
|
|
return _u.SetTeamID(v.ID)
|
|
}
|
|
|
|
// SetSpouseID sets the "spouse" edge to the User entity by ID.
|
|
func (_u *UserUpdate) SetSpouseID(id string) *UserUpdate {
|
|
_u.mutation.SetSpouseID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSpouseID sets the "spouse" edge to the User entity by ID if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableSpouseID(id *string) *UserUpdate {
|
|
if id != nil {
|
|
_u = _u.SetSpouseID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSpouse sets the "spouse" edge to the User entity.
|
|
func (_u *UserUpdate) SetSpouse(v *User) *UserUpdate {
|
|
return _u.SetSpouseID(v.ID)
|
|
}
|
|
|
|
// AddChildIDs adds the "children" edge to the User entity by IDs.
|
|
func (_u *UserUpdate) AddChildIDs(ids ...string) *UserUpdate {
|
|
_u.mutation.AddChildIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddChildren adds the "children" edges to the User entity.
|
|
func (_u *UserUpdate) AddChildren(v ...*User) *UserUpdate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddChildIDs(ids...)
|
|
}
|
|
|
|
// SetParentID sets the "parent" edge to the User entity by ID.
|
|
func (_u *UserUpdate) SetParentID(id string) *UserUpdate {
|
|
_u.mutation.SetParentID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableParentID sets the "parent" edge to the User entity by ID if the given value is not nil.
|
|
func (_u *UserUpdate) SetNillableParentID(id *string) *UserUpdate {
|
|
if id != nil {
|
|
_u = _u.SetParentID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetParent sets the "parent" edge to the User entity.
|
|
func (_u *UserUpdate) SetParent(v *User) *UserUpdate {
|
|
return _u.SetParentID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the UserMutation object of the builder.
|
|
func (_u *UserUpdate) Mutation() *UserMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearCard clears the "card" edge to the Card entity.
|
|
func (_u *UserUpdate) ClearCard() *UserUpdate {
|
|
_u.mutation.ClearCard()
|
|
return _u
|
|
}
|
|
|
|
// ClearPets clears all "pets" edges to the Pet entity.
|
|
func (_u *UserUpdate) ClearPets() *UserUpdate {
|
|
_u.mutation.ClearPets()
|
|
return _u
|
|
}
|
|
|
|
// RemovePetIDs removes the "pets" edge to Pet entities by IDs.
|
|
func (_u *UserUpdate) RemovePetIDs(ids ...string) *UserUpdate {
|
|
_u.mutation.RemovePetIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemovePets removes "pets" edges to Pet entities.
|
|
func (_u *UserUpdate) RemovePets(v ...*Pet) *UserUpdate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemovePetIDs(ids...)
|
|
}
|
|
|
|
// ClearFiles clears all "files" edges to the File entity.
|
|
func (_u *UserUpdate) ClearFiles() *UserUpdate {
|
|
_u.mutation.ClearFiles()
|
|
return _u
|
|
}
|
|
|
|
// RemoveFileIDs removes the "files" edge to File entities by IDs.
|
|
func (_u *UserUpdate) RemoveFileIDs(ids ...string) *UserUpdate {
|
|
_u.mutation.RemoveFileIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveFiles removes "files" edges to File entities.
|
|
func (_u *UserUpdate) RemoveFiles(v ...*File) *UserUpdate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveFileIDs(ids...)
|
|
}
|
|
|
|
// ClearGroups clears all "groups" edges to the Group entity.
|
|
func (_u *UserUpdate) ClearGroups() *UserUpdate {
|
|
_u.mutation.ClearGroups()
|
|
return _u
|
|
}
|
|
|
|
// RemoveGroupIDs removes the "groups" edge to Group entities by IDs.
|
|
func (_u *UserUpdate) RemoveGroupIDs(ids ...string) *UserUpdate {
|
|
_u.mutation.RemoveGroupIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveGroups removes "groups" edges to Group entities.
|
|
func (_u *UserUpdate) RemoveGroups(v ...*Group) *UserUpdate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveGroupIDs(ids...)
|
|
}
|
|
|
|
// ClearFriends clears all "friends" edges to the User entity.
|
|
func (_u *UserUpdate) ClearFriends() *UserUpdate {
|
|
_u.mutation.ClearFriends()
|
|
return _u
|
|
}
|
|
|
|
// RemoveFriendIDs removes the "friends" edge to User entities by IDs.
|
|
func (_u *UserUpdate) RemoveFriendIDs(ids ...string) *UserUpdate {
|
|
_u.mutation.RemoveFriendIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveFriends removes "friends" edges to User entities.
|
|
func (_u *UserUpdate) RemoveFriends(v ...*User) *UserUpdate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveFriendIDs(ids...)
|
|
}
|
|
|
|
// ClearFollowers clears all "followers" edges to the User entity.
|
|
func (_u *UserUpdate) ClearFollowers() *UserUpdate {
|
|
_u.mutation.ClearFollowers()
|
|
return _u
|
|
}
|
|
|
|
// RemoveFollowerIDs removes the "followers" edge to User entities by IDs.
|
|
func (_u *UserUpdate) RemoveFollowerIDs(ids ...string) *UserUpdate {
|
|
_u.mutation.RemoveFollowerIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveFollowers removes "followers" edges to User entities.
|
|
func (_u *UserUpdate) RemoveFollowers(v ...*User) *UserUpdate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveFollowerIDs(ids...)
|
|
}
|
|
|
|
// ClearFollowing clears all "following" edges to the User entity.
|
|
func (_u *UserUpdate) ClearFollowing() *UserUpdate {
|
|
_u.mutation.ClearFollowing()
|
|
return _u
|
|
}
|
|
|
|
// RemoveFollowingIDs removes the "following" edge to User entities by IDs.
|
|
func (_u *UserUpdate) RemoveFollowingIDs(ids ...string) *UserUpdate {
|
|
_u.mutation.RemoveFollowingIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveFollowing removes "following" edges to User entities.
|
|
func (_u *UserUpdate) RemoveFollowing(v ...*User) *UserUpdate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveFollowingIDs(ids...)
|
|
}
|
|
|
|
// ClearTeam clears the "team" edge to the Pet entity.
|
|
func (_u *UserUpdate) ClearTeam() *UserUpdate {
|
|
_u.mutation.ClearTeam()
|
|
return _u
|
|
}
|
|
|
|
// ClearSpouse clears the "spouse" edge to the User entity.
|
|
func (_u *UserUpdate) ClearSpouse() *UserUpdate {
|
|
_u.mutation.ClearSpouse()
|
|
return _u
|
|
}
|
|
|
|
// ClearChildren clears all "children" edges to the User entity.
|
|
func (_u *UserUpdate) ClearChildren() *UserUpdate {
|
|
_u.mutation.ClearChildren()
|
|
return _u
|
|
}
|
|
|
|
// RemoveChildIDs removes the "children" edge to User entities by IDs.
|
|
func (_u *UserUpdate) RemoveChildIDs(ids ...string) *UserUpdate {
|
|
_u.mutation.RemoveChildIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveChildren removes "children" edges to User entities.
|
|
func (_u *UserUpdate) RemoveChildren(v ...*User) *UserUpdate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveChildIDs(ids...)
|
|
}
|
|
|
|
// ClearParent clears the "parent" edge to the User entity.
|
|
func (_u *UserUpdate) ClearParent() *UserUpdate {
|
|
_u.mutation.ClearParent()
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *UserUpdate) Save(ctx context.Context) (int, error) {
|
|
return withHooks(ctx, _u.gremlinSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *UserUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *UserUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *UserUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *UserUpdate) check() error {
|
|
if v, ok := _u.mutation.OptionalInt(); ok {
|
|
if err := user.OptionalIntValidator(v); err != nil {
|
|
return &ValidationError{Name: "optional_int", err: fmt.Errorf(`ent: validator failed for field "User.optional_int": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Role(); ok {
|
|
if err := user.RoleValidator(v); err != nil {
|
|
return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "User.role": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Employment(); ok {
|
|
if err := user.EmploymentValidator(v); err != nil {
|
|
return &ValidationError{Name: "employment", err: fmt.Errorf(`ent: validator failed for field "User.employment": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *UserUpdate) gremlinSave(ctx context.Context) (int, error) {
|
|
if err := _u.check(); err != nil {
|
|
return 0, err
|
|
}
|
|
res := &gremlin.Response{}
|
|
query, bindings := _u.gremlin().Query()
|
|
if err := _u.driver.Exec(ctx, query, bindings, res); err != nil {
|
|
return 0, err
|
|
}
|
|
if err, ok := isConstantError(res); ok {
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return res.ReadInt()
|
|
}
|
|
|
|
func (_u *UserUpdate) gremlin() *dsl.Traversal {
|
|
type constraint struct {
|
|
pred *dsl.Traversal // constraint predicate.
|
|
test *dsl.Traversal // test matches and its constant.
|
|
}
|
|
constraints := make([]*constraint, 0, 8)
|
|
v := g.V().HasLabel(user.Label)
|
|
for _, p := range _u.mutation.Predicates() {
|
|
p(v)
|
|
}
|
|
var (
|
|
rv = v.Clone()
|
|
_ = rv
|
|
|
|
trs []*dsl.Traversal
|
|
)
|
|
if value, ok := _u.mutation.OptionalInt(); ok {
|
|
v.Property(dsl.Single, user.FieldOptionalInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedOptionalInt(); ok {
|
|
v.Property(dsl.Single, user.FieldOptionalInt, __.Union(__.Values(user.FieldOptionalInt), __.Constant(value)).Sum())
|
|
}
|
|
if value, ok := _u.mutation.Age(); ok {
|
|
v.Property(dsl.Single, user.FieldAge, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedAge(); ok {
|
|
v.Property(dsl.Single, user.FieldAge, __.Union(__.Values(user.FieldAge), __.Constant(value)).Sum())
|
|
}
|
|
if value, ok := _u.mutation.Name(); ok {
|
|
v.Property(dsl.Single, user.FieldName, value)
|
|
}
|
|
if value, ok := _u.mutation.Last(); ok {
|
|
v.Property(dsl.Single, user.FieldLast, value)
|
|
}
|
|
if value, ok := _u.mutation.Nickname(); ok {
|
|
constraints = append(constraints, &constraint{
|
|
pred: g.V().Has(user.Label, user.FieldNickname, value).Count(),
|
|
test: __.Is(p.NEQ(0)).Constant(NewErrUniqueField(user.Label, user.FieldNickname, value)),
|
|
})
|
|
v.Property(dsl.Single, user.FieldNickname, value)
|
|
}
|
|
if value, ok := _u.mutation.Address(); ok {
|
|
v.Property(dsl.Single, user.FieldAddress, value)
|
|
}
|
|
if value, ok := _u.mutation.Phone(); ok {
|
|
constraints = append(constraints, &constraint{
|
|
pred: g.V().Has(user.Label, user.FieldPhone, value).Count(),
|
|
test: __.Is(p.NEQ(0)).Constant(NewErrUniqueField(user.Label, user.FieldPhone, value)),
|
|
})
|
|
v.Property(dsl.Single, user.FieldPhone, value)
|
|
}
|
|
if value, ok := _u.mutation.Password(); ok {
|
|
v.Property(dsl.Single, user.FieldPassword, value)
|
|
}
|
|
if value, ok := _u.mutation.Role(); ok {
|
|
v.Property(dsl.Single, user.FieldRole, value)
|
|
}
|
|
if value, ok := _u.mutation.Employment(); ok {
|
|
v.Property(dsl.Single, user.FieldEmployment, value)
|
|
}
|
|
if value, ok := _u.mutation.SSOCert(); ok {
|
|
v.Property(dsl.Single, user.FieldSSOCert, value)
|
|
}
|
|
if value, ok := _u.mutation.FilesCount(); ok {
|
|
v.Property(dsl.Single, user.FieldFilesCount, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedFilesCount(); ok {
|
|
v.Property(dsl.Single, user.FieldFilesCount, __.Union(__.Values(user.FieldFilesCount), __.Constant(value)).Sum())
|
|
}
|
|
var properties []any
|
|
if _u.mutation.OptionalIntCleared() {
|
|
properties = append(properties, user.FieldOptionalInt)
|
|
}
|
|
if _u.mutation.NicknameCleared() {
|
|
properties = append(properties, user.FieldNickname)
|
|
}
|
|
if _u.mutation.AddressCleared() {
|
|
properties = append(properties, user.FieldAddress)
|
|
}
|
|
if _u.mutation.PhoneCleared() {
|
|
properties = append(properties, user.FieldPhone)
|
|
}
|
|
if _u.mutation.PasswordCleared() {
|
|
properties = append(properties, user.FieldPassword)
|
|
}
|
|
if _u.mutation.SSOCertCleared() {
|
|
properties = append(properties, user.FieldSSOCert)
|
|
}
|
|
if _u.mutation.FilesCountCleared() {
|
|
properties = append(properties, user.FieldFilesCount)
|
|
}
|
|
if len(properties) > 0 {
|
|
v.SideEffect(__.Properties(properties...).Drop())
|
|
}
|
|
if _u.mutation.CardCleared() {
|
|
tr := rv.Clone().OutE(user.CardLabel).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.CardIDs() {
|
|
v.AddE(user.CardLabel).To(g.V(id)).OutV()
|
|
constraints = append(constraints, &constraint{
|
|
pred: g.E().HasLabel(user.CardLabel).InV().HasID(id).Count(),
|
|
test: __.Is(p.NEQ(0)).Constant(NewErrUniqueEdge(user.Label, user.CardLabel, id)),
|
|
})
|
|
}
|
|
for _, id := range _u.mutation.RemovedPetsIDs() {
|
|
tr := rv.Clone().OutE(user.PetsLabel).Where(__.OtherV().HasID(id)).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.PetsIDs() {
|
|
v.AddE(user.PetsLabel).To(g.V(id)).OutV()
|
|
constraints = append(constraints, &constraint{
|
|
pred: g.E().HasLabel(user.PetsLabel).InV().HasID(id).Count(),
|
|
test: __.Is(p.NEQ(0)).Constant(NewErrUniqueEdge(user.Label, user.PetsLabel, id)),
|
|
})
|
|
}
|
|
for _, id := range _u.mutation.RemovedFilesIDs() {
|
|
tr := rv.Clone().OutE(user.FilesLabel).Where(__.OtherV().HasID(id)).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.FilesIDs() {
|
|
v.AddE(user.FilesLabel).To(g.V(id)).OutV()
|
|
constraints = append(constraints, &constraint{
|
|
pred: g.E().HasLabel(user.FilesLabel).InV().HasID(id).Count(),
|
|
test: __.Is(p.NEQ(0)).Constant(NewErrUniqueEdge(user.Label, user.FilesLabel, id)),
|
|
})
|
|
}
|
|
for _, id := range _u.mutation.RemovedGroupsIDs() {
|
|
tr := rv.Clone().OutE(user.GroupsLabel).Where(__.OtherV().HasID(id)).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.GroupsIDs() {
|
|
v.AddE(user.GroupsLabel).To(g.V(id)).OutV()
|
|
}
|
|
for _, id := range _u.mutation.RemovedFriendsIDs() {
|
|
tr := rv.Clone().BothE(user.FriendsLabel).Where(__.Or(__.InV().HasID(id), __.OutV().HasID(id))).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.FriendsIDs() {
|
|
v.AddE(user.FriendsLabel).To(g.V(id)).OutV()
|
|
}
|
|
for _, id := range _u.mutation.RemovedFollowersIDs() {
|
|
tr := rv.Clone().InE(user.FollowingLabel).Where(__.OtherV().HasID(id)).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.FollowersIDs() {
|
|
v.AddE(user.FollowingLabel).From(g.V(id)).InV()
|
|
}
|
|
for _, id := range _u.mutation.RemovedFollowingIDs() {
|
|
tr := rv.Clone().OutE(user.FollowingLabel).Where(__.OtherV().HasID(id)).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.FollowingIDs() {
|
|
v.AddE(user.FollowingLabel).To(g.V(id)).OutV()
|
|
}
|
|
if _u.mutation.TeamCleared() {
|
|
tr := rv.Clone().OutE(user.TeamLabel).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.TeamIDs() {
|
|
v.AddE(user.TeamLabel).To(g.V(id)).OutV()
|
|
constraints = append(constraints, &constraint{
|
|
pred: g.E().HasLabel(user.TeamLabel).InV().HasID(id).Count(),
|
|
test: __.Is(p.NEQ(0)).Constant(NewErrUniqueEdge(user.Label, user.TeamLabel, id)),
|
|
})
|
|
}
|
|
if _u.mutation.SpouseCleared() {
|
|
tr := rv.Clone().BothE(user.SpouseLabel).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.SpouseIDs() {
|
|
v.AddE(user.SpouseLabel).To(g.V(id)).OutV()
|
|
constraints = append(constraints, &constraint{
|
|
pred: rv.Clone().Both(user.SpouseLabel).Count(),
|
|
test: __.Is(p.NEQ(0)).Constant(NewErrUniqueEdge(user.Label, user.SpouseLabel, id)),
|
|
})
|
|
constraints = append(constraints, &constraint{
|
|
pred: g.E().HasLabel(user.SpouseLabel).Where(__.Or(__.InV().HasID(id), __.OutV().HasID(id))).Count(),
|
|
test: __.Is(p.NEQ(0)).Constant(NewErrUniqueEdge(user.Label, user.SpouseLabel, id)),
|
|
})
|
|
}
|
|
for _, id := range _u.mutation.RemovedChildrenIDs() {
|
|
tr := rv.Clone().InE(user.ParentLabel).Where(__.OtherV().HasID(id)).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.ChildrenIDs() {
|
|
v.AddE(user.ParentLabel).From(g.V(id)).InV()
|
|
constraints = append(constraints, &constraint{
|
|
pred: g.E().HasLabel(user.ParentLabel).OutV().HasID(id).Count(),
|
|
test: __.Is(p.NEQ(0)).Constant(NewErrUniqueEdge(user.Label, user.ParentLabel, id)),
|
|
})
|
|
}
|
|
if _u.mutation.ParentCleared() {
|
|
tr := rv.Clone().OutE(user.ParentLabel).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.ParentIDs() {
|
|
v.AddE(user.ParentLabel).To(g.V(id)).OutV()
|
|
}
|
|
v.Count()
|
|
if len(constraints) > 0 {
|
|
constraints = append(constraints, &constraint{
|
|
pred: rv.Count(),
|
|
test: __.Is(p.GT(1)).Constant(&ConstraintError{msg: "update traversal contains more than one vertex"}),
|
|
})
|
|
v = constraints[0].pred.Coalesce(constraints[0].test, v)
|
|
for _, cr := range constraints[1:] {
|
|
v = cr.pred.Coalesce(cr.test, v)
|
|
}
|
|
}
|
|
trs = append(trs, v)
|
|
return dsl.Join(trs...)
|
|
}
|
|
|
|
// UserUpdateOne is the builder for updating a single User entity.
|
|
type UserUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *UserMutation
|
|
}
|
|
|
|
// SetOptionalInt sets the "optional_int" field.
|
|
func (_u *UserUpdateOne) SetOptionalInt(v int) *UserUpdateOne {
|
|
_u.mutation.ResetOptionalInt()
|
|
_u.mutation.SetOptionalInt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOptionalInt sets the "optional_int" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableOptionalInt(v *int) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetOptionalInt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddOptionalInt adds value to the "optional_int" field.
|
|
func (_u *UserUpdateOne) AddOptionalInt(v int) *UserUpdateOne {
|
|
_u.mutation.AddOptionalInt(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearOptionalInt clears the value of the "optional_int" field.
|
|
func (_u *UserUpdateOne) ClearOptionalInt() *UserUpdateOne {
|
|
_u.mutation.ClearOptionalInt()
|
|
return _u
|
|
}
|
|
|
|
// SetAge sets the "age" field.
|
|
func (_u *UserUpdateOne) SetAge(v int) *UserUpdateOne {
|
|
_u.mutation.ResetAge()
|
|
_u.mutation.SetAge(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAge sets the "age" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableAge(v *int) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetAge(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddAge adds value to the "age" field.
|
|
func (_u *UserUpdateOne) AddAge(v int) *UserUpdateOne {
|
|
_u.mutation.AddAge(v)
|
|
return _u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_u *UserUpdateOne) SetName(v string) *UserUpdateOne {
|
|
_u.mutation.SetName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableName(v *string) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetLast sets the "last" field.
|
|
func (_u *UserUpdateOne) SetLast(v string) *UserUpdateOne {
|
|
_u.mutation.SetLast(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLast sets the "last" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableLast(v *string) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetLast(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetNickname sets the "nickname" field.
|
|
func (_u *UserUpdateOne) SetNickname(v string) *UserUpdateOne {
|
|
_u.mutation.SetNickname(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableNickname sets the "nickname" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableNickname(v *string) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetNickname(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearNickname clears the value of the "nickname" field.
|
|
func (_u *UserUpdateOne) ClearNickname() *UserUpdateOne {
|
|
_u.mutation.ClearNickname()
|
|
return _u
|
|
}
|
|
|
|
// SetAddress sets the "address" field.
|
|
func (_u *UserUpdateOne) SetAddress(v string) *UserUpdateOne {
|
|
_u.mutation.SetAddress(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAddress sets the "address" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableAddress(v *string) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetAddress(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearAddress clears the value of the "address" field.
|
|
func (_u *UserUpdateOne) ClearAddress() *UserUpdateOne {
|
|
_u.mutation.ClearAddress()
|
|
return _u
|
|
}
|
|
|
|
// SetPhone sets the "phone" field.
|
|
func (_u *UserUpdateOne) SetPhone(v string) *UserUpdateOne {
|
|
_u.mutation.SetPhone(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePhone sets the "phone" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillablePhone(v *string) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetPhone(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearPhone clears the value of the "phone" field.
|
|
func (_u *UserUpdateOne) ClearPhone() *UserUpdateOne {
|
|
_u.mutation.ClearPhone()
|
|
return _u
|
|
}
|
|
|
|
// SetPassword sets the "password" field.
|
|
func (_u *UserUpdateOne) SetPassword(v string) *UserUpdateOne {
|
|
_u.mutation.SetPassword(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePassword sets the "password" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillablePassword(v *string) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetPassword(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearPassword clears the value of the "password" field.
|
|
func (_u *UserUpdateOne) ClearPassword() *UserUpdateOne {
|
|
_u.mutation.ClearPassword()
|
|
return _u
|
|
}
|
|
|
|
// SetRole sets the "role" field.
|
|
func (_u *UserUpdateOne) SetRole(v user.Role) *UserUpdateOne {
|
|
_u.mutation.SetRole(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRole sets the "role" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableRole(v *user.Role) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetRole(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetEmployment sets the "employment" field.
|
|
func (_u *UserUpdateOne) SetEmployment(v user.Employment) *UserUpdateOne {
|
|
_u.mutation.SetEmployment(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEmployment sets the "employment" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableEmployment(v *user.Employment) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetEmployment(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSSOCert sets the "SSOCert" field.
|
|
func (_u *UserUpdateOne) SetSSOCert(v string) *UserUpdateOne {
|
|
_u.mutation.SetSSOCert(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSSOCert sets the "SSOCert" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableSSOCert(v *string) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetSSOCert(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSSOCert clears the value of the "SSOCert" field.
|
|
func (_u *UserUpdateOne) ClearSSOCert() *UserUpdateOne {
|
|
_u.mutation.ClearSSOCert()
|
|
return _u
|
|
}
|
|
|
|
// SetFilesCount sets the "files_count" field.
|
|
func (_u *UserUpdateOne) SetFilesCount(v int) *UserUpdateOne {
|
|
_u.mutation.ResetFilesCount()
|
|
_u.mutation.SetFilesCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableFilesCount sets the "files_count" field if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableFilesCount(v *int) *UserUpdateOne {
|
|
if v != nil {
|
|
_u.SetFilesCount(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddFilesCount adds value to the "files_count" field.
|
|
func (_u *UserUpdateOne) AddFilesCount(v int) *UserUpdateOne {
|
|
_u.mutation.AddFilesCount(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearFilesCount clears the value of the "files_count" field.
|
|
func (_u *UserUpdateOne) ClearFilesCount() *UserUpdateOne {
|
|
_u.mutation.ClearFilesCount()
|
|
return _u
|
|
}
|
|
|
|
// SetCardID sets the "card" edge to the Card entity by ID.
|
|
func (_u *UserUpdateOne) SetCardID(id string) *UserUpdateOne {
|
|
_u.mutation.SetCardID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCardID sets the "card" edge to the Card entity by ID if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableCardID(id *string) *UserUpdateOne {
|
|
if id != nil {
|
|
_u = _u.SetCardID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCard sets the "card" edge to the Card entity.
|
|
func (_u *UserUpdateOne) SetCard(v *Card) *UserUpdateOne {
|
|
return _u.SetCardID(v.ID)
|
|
}
|
|
|
|
// AddPetIDs adds the "pets" edge to the Pet entity by IDs.
|
|
func (_u *UserUpdateOne) AddPetIDs(ids ...string) *UserUpdateOne {
|
|
_u.mutation.AddPetIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddPets adds the "pets" edges to the Pet entity.
|
|
func (_u *UserUpdateOne) AddPets(v ...*Pet) *UserUpdateOne {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddPetIDs(ids...)
|
|
}
|
|
|
|
// AddFileIDs adds the "files" edge to the File entity by IDs.
|
|
func (_u *UserUpdateOne) AddFileIDs(ids ...string) *UserUpdateOne {
|
|
_u.mutation.AddFileIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddFiles adds the "files" edges to the File entity.
|
|
func (_u *UserUpdateOne) AddFiles(v ...*File) *UserUpdateOne {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddFileIDs(ids...)
|
|
}
|
|
|
|
// AddGroupIDs adds the "groups" edge to the Group entity by IDs.
|
|
func (_u *UserUpdateOne) AddGroupIDs(ids ...string) *UserUpdateOne {
|
|
_u.mutation.AddGroupIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddGroups adds the "groups" edges to the Group entity.
|
|
func (_u *UserUpdateOne) AddGroups(v ...*Group) *UserUpdateOne {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddGroupIDs(ids...)
|
|
}
|
|
|
|
// AddFriendIDs adds the "friends" edge to the User entity by IDs.
|
|
func (_u *UserUpdateOne) AddFriendIDs(ids ...string) *UserUpdateOne {
|
|
_u.mutation.AddFriendIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddFriends adds the "friends" edges to the User entity.
|
|
func (_u *UserUpdateOne) AddFriends(v ...*User) *UserUpdateOne {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddFriendIDs(ids...)
|
|
}
|
|
|
|
// AddFollowerIDs adds the "followers" edge to the User entity by IDs.
|
|
func (_u *UserUpdateOne) AddFollowerIDs(ids ...string) *UserUpdateOne {
|
|
_u.mutation.AddFollowerIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddFollowers adds the "followers" edges to the User entity.
|
|
func (_u *UserUpdateOne) AddFollowers(v ...*User) *UserUpdateOne {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddFollowerIDs(ids...)
|
|
}
|
|
|
|
// AddFollowingIDs adds the "following" edge to the User entity by IDs.
|
|
func (_u *UserUpdateOne) AddFollowingIDs(ids ...string) *UserUpdateOne {
|
|
_u.mutation.AddFollowingIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddFollowing adds the "following" edges to the User entity.
|
|
func (_u *UserUpdateOne) AddFollowing(v ...*User) *UserUpdateOne {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddFollowingIDs(ids...)
|
|
}
|
|
|
|
// SetTeamID sets the "team" edge to the Pet entity by ID.
|
|
func (_u *UserUpdateOne) SetTeamID(id string) *UserUpdateOne {
|
|
_u.mutation.SetTeamID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTeamID sets the "team" edge to the Pet entity by ID if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableTeamID(id *string) *UserUpdateOne {
|
|
if id != nil {
|
|
_u = _u.SetTeamID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetTeam sets the "team" edge to the Pet entity.
|
|
func (_u *UserUpdateOne) SetTeam(v *Pet) *UserUpdateOne {
|
|
return _u.SetTeamID(v.ID)
|
|
}
|
|
|
|
// SetSpouseID sets the "spouse" edge to the User entity by ID.
|
|
func (_u *UserUpdateOne) SetSpouseID(id string) *UserUpdateOne {
|
|
_u.mutation.SetSpouseID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSpouseID sets the "spouse" edge to the User entity by ID if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableSpouseID(id *string) *UserUpdateOne {
|
|
if id != nil {
|
|
_u = _u.SetSpouseID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSpouse sets the "spouse" edge to the User entity.
|
|
func (_u *UserUpdateOne) SetSpouse(v *User) *UserUpdateOne {
|
|
return _u.SetSpouseID(v.ID)
|
|
}
|
|
|
|
// AddChildIDs adds the "children" edge to the User entity by IDs.
|
|
func (_u *UserUpdateOne) AddChildIDs(ids ...string) *UserUpdateOne {
|
|
_u.mutation.AddChildIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddChildren adds the "children" edges to the User entity.
|
|
func (_u *UserUpdateOne) AddChildren(v ...*User) *UserUpdateOne {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddChildIDs(ids...)
|
|
}
|
|
|
|
// SetParentID sets the "parent" edge to the User entity by ID.
|
|
func (_u *UserUpdateOne) SetParentID(id string) *UserUpdateOne {
|
|
_u.mutation.SetParentID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableParentID sets the "parent" edge to the User entity by ID if the given value is not nil.
|
|
func (_u *UserUpdateOne) SetNillableParentID(id *string) *UserUpdateOne {
|
|
if id != nil {
|
|
_u = _u.SetParentID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetParent sets the "parent" edge to the User entity.
|
|
func (_u *UserUpdateOne) SetParent(v *User) *UserUpdateOne {
|
|
return _u.SetParentID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the UserMutation object of the builder.
|
|
func (_u *UserUpdateOne) Mutation() *UserMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearCard clears the "card" edge to the Card entity.
|
|
func (_u *UserUpdateOne) ClearCard() *UserUpdateOne {
|
|
_u.mutation.ClearCard()
|
|
return _u
|
|
}
|
|
|
|
// ClearPets clears all "pets" edges to the Pet entity.
|
|
func (_u *UserUpdateOne) ClearPets() *UserUpdateOne {
|
|
_u.mutation.ClearPets()
|
|
return _u
|
|
}
|
|
|
|
// RemovePetIDs removes the "pets" edge to Pet entities by IDs.
|
|
func (_u *UserUpdateOne) RemovePetIDs(ids ...string) *UserUpdateOne {
|
|
_u.mutation.RemovePetIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemovePets removes "pets" edges to Pet entities.
|
|
func (_u *UserUpdateOne) RemovePets(v ...*Pet) *UserUpdateOne {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemovePetIDs(ids...)
|
|
}
|
|
|
|
// ClearFiles clears all "files" edges to the File entity.
|
|
func (_u *UserUpdateOne) ClearFiles() *UserUpdateOne {
|
|
_u.mutation.ClearFiles()
|
|
return _u
|
|
}
|
|
|
|
// RemoveFileIDs removes the "files" edge to File entities by IDs.
|
|
func (_u *UserUpdateOne) RemoveFileIDs(ids ...string) *UserUpdateOne {
|
|
_u.mutation.RemoveFileIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveFiles removes "files" edges to File entities.
|
|
func (_u *UserUpdateOne) RemoveFiles(v ...*File) *UserUpdateOne {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveFileIDs(ids...)
|
|
}
|
|
|
|
// ClearGroups clears all "groups" edges to the Group entity.
|
|
func (_u *UserUpdateOne) ClearGroups() *UserUpdateOne {
|
|
_u.mutation.ClearGroups()
|
|
return _u
|
|
}
|
|
|
|
// RemoveGroupIDs removes the "groups" edge to Group entities by IDs.
|
|
func (_u *UserUpdateOne) RemoveGroupIDs(ids ...string) *UserUpdateOne {
|
|
_u.mutation.RemoveGroupIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveGroups removes "groups" edges to Group entities.
|
|
func (_u *UserUpdateOne) RemoveGroups(v ...*Group) *UserUpdateOne {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveGroupIDs(ids...)
|
|
}
|
|
|
|
// ClearFriends clears all "friends" edges to the User entity.
|
|
func (_u *UserUpdateOne) ClearFriends() *UserUpdateOne {
|
|
_u.mutation.ClearFriends()
|
|
return _u
|
|
}
|
|
|
|
// RemoveFriendIDs removes the "friends" edge to User entities by IDs.
|
|
func (_u *UserUpdateOne) RemoveFriendIDs(ids ...string) *UserUpdateOne {
|
|
_u.mutation.RemoveFriendIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveFriends removes "friends" edges to User entities.
|
|
func (_u *UserUpdateOne) RemoveFriends(v ...*User) *UserUpdateOne {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveFriendIDs(ids...)
|
|
}
|
|
|
|
// ClearFollowers clears all "followers" edges to the User entity.
|
|
func (_u *UserUpdateOne) ClearFollowers() *UserUpdateOne {
|
|
_u.mutation.ClearFollowers()
|
|
return _u
|
|
}
|
|
|
|
// RemoveFollowerIDs removes the "followers" edge to User entities by IDs.
|
|
func (_u *UserUpdateOne) RemoveFollowerIDs(ids ...string) *UserUpdateOne {
|
|
_u.mutation.RemoveFollowerIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveFollowers removes "followers" edges to User entities.
|
|
func (_u *UserUpdateOne) RemoveFollowers(v ...*User) *UserUpdateOne {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveFollowerIDs(ids...)
|
|
}
|
|
|
|
// ClearFollowing clears all "following" edges to the User entity.
|
|
func (_u *UserUpdateOne) ClearFollowing() *UserUpdateOne {
|
|
_u.mutation.ClearFollowing()
|
|
return _u
|
|
}
|
|
|
|
// RemoveFollowingIDs removes the "following" edge to User entities by IDs.
|
|
func (_u *UserUpdateOne) RemoveFollowingIDs(ids ...string) *UserUpdateOne {
|
|
_u.mutation.RemoveFollowingIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveFollowing removes "following" edges to User entities.
|
|
func (_u *UserUpdateOne) RemoveFollowing(v ...*User) *UserUpdateOne {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveFollowingIDs(ids...)
|
|
}
|
|
|
|
// ClearTeam clears the "team" edge to the Pet entity.
|
|
func (_u *UserUpdateOne) ClearTeam() *UserUpdateOne {
|
|
_u.mutation.ClearTeam()
|
|
return _u
|
|
}
|
|
|
|
// ClearSpouse clears the "spouse" edge to the User entity.
|
|
func (_u *UserUpdateOne) ClearSpouse() *UserUpdateOne {
|
|
_u.mutation.ClearSpouse()
|
|
return _u
|
|
}
|
|
|
|
// ClearChildren clears all "children" edges to the User entity.
|
|
func (_u *UserUpdateOne) ClearChildren() *UserUpdateOne {
|
|
_u.mutation.ClearChildren()
|
|
return _u
|
|
}
|
|
|
|
// RemoveChildIDs removes the "children" edge to User entities by IDs.
|
|
func (_u *UserUpdateOne) RemoveChildIDs(ids ...string) *UserUpdateOne {
|
|
_u.mutation.RemoveChildIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveChildren removes "children" edges to User entities.
|
|
func (_u *UserUpdateOne) RemoveChildren(v ...*User) *UserUpdateOne {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveChildIDs(ids...)
|
|
}
|
|
|
|
// ClearParent clears the "parent" edge to the User entity.
|
|
func (_u *UserUpdateOne) ClearParent() *UserUpdateOne {
|
|
_u.mutation.ClearParent()
|
|
return _u
|
|
}
|
|
|
|
// Where appends a list predicates to the UserUpdate builder.
|
|
func (_u *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (_u *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated User entity.
|
|
func (_u *UserUpdateOne) Save(ctx context.Context) (*User, error) {
|
|
return withHooks(ctx, _u.gremlinSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *UserUpdateOne) SaveX(ctx context.Context) *User {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *UserUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *UserUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *UserUpdateOne) check() error {
|
|
if v, ok := _u.mutation.OptionalInt(); ok {
|
|
if err := user.OptionalIntValidator(v); err != nil {
|
|
return &ValidationError{Name: "optional_int", err: fmt.Errorf(`ent: validator failed for field "User.optional_int": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Role(); ok {
|
|
if err := user.RoleValidator(v); err != nil {
|
|
return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "User.role": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Employment(); ok {
|
|
if err := user.EmploymentValidator(v); err != nil {
|
|
return &ValidationError{Name: "employment", err: fmt.Errorf(`ent: validator failed for field "User.employment": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *UserUpdateOne) gremlinSave(ctx context.Context) (*User, error) {
|
|
if err := _u.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
res := &gremlin.Response{}
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "User.id" for update`)}
|
|
}
|
|
query, bindings := _u.gremlin(id).Query()
|
|
if err := _u.driver.Exec(ctx, query, bindings, res); err != nil {
|
|
return nil, err
|
|
}
|
|
if err, ok := isConstantError(res); ok {
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
_m := &User{config: _u.config}
|
|
if err := _m.FromResponse(res); err != nil {
|
|
return nil, err
|
|
}
|
|
return _m, nil
|
|
}
|
|
|
|
func (_u *UserUpdateOne) gremlin(id string) *dsl.Traversal {
|
|
type constraint struct {
|
|
pred *dsl.Traversal // constraint predicate.
|
|
test *dsl.Traversal // test matches and its constant.
|
|
}
|
|
constraints := make([]*constraint, 0, 8)
|
|
v := g.V(id)
|
|
var (
|
|
rv = v.Clone()
|
|
_ = rv
|
|
|
|
trs []*dsl.Traversal
|
|
)
|
|
if value, ok := _u.mutation.OptionalInt(); ok {
|
|
v.Property(dsl.Single, user.FieldOptionalInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedOptionalInt(); ok {
|
|
v.Property(dsl.Single, user.FieldOptionalInt, __.Union(__.Values(user.FieldOptionalInt), __.Constant(value)).Sum())
|
|
}
|
|
if value, ok := _u.mutation.Age(); ok {
|
|
v.Property(dsl.Single, user.FieldAge, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedAge(); ok {
|
|
v.Property(dsl.Single, user.FieldAge, __.Union(__.Values(user.FieldAge), __.Constant(value)).Sum())
|
|
}
|
|
if value, ok := _u.mutation.Name(); ok {
|
|
v.Property(dsl.Single, user.FieldName, value)
|
|
}
|
|
if value, ok := _u.mutation.Last(); ok {
|
|
v.Property(dsl.Single, user.FieldLast, value)
|
|
}
|
|
if value, ok := _u.mutation.Nickname(); ok {
|
|
constraints = append(constraints, &constraint{
|
|
pred: g.V().Has(user.Label, user.FieldNickname, value).Count(),
|
|
test: __.Is(p.NEQ(0)).Constant(NewErrUniqueField(user.Label, user.FieldNickname, value)),
|
|
})
|
|
v.Property(dsl.Single, user.FieldNickname, value)
|
|
}
|
|
if value, ok := _u.mutation.Address(); ok {
|
|
v.Property(dsl.Single, user.FieldAddress, value)
|
|
}
|
|
if value, ok := _u.mutation.Phone(); ok {
|
|
constraints = append(constraints, &constraint{
|
|
pred: g.V().Has(user.Label, user.FieldPhone, value).Count(),
|
|
test: __.Is(p.NEQ(0)).Constant(NewErrUniqueField(user.Label, user.FieldPhone, value)),
|
|
})
|
|
v.Property(dsl.Single, user.FieldPhone, value)
|
|
}
|
|
if value, ok := _u.mutation.Password(); ok {
|
|
v.Property(dsl.Single, user.FieldPassword, value)
|
|
}
|
|
if value, ok := _u.mutation.Role(); ok {
|
|
v.Property(dsl.Single, user.FieldRole, value)
|
|
}
|
|
if value, ok := _u.mutation.Employment(); ok {
|
|
v.Property(dsl.Single, user.FieldEmployment, value)
|
|
}
|
|
if value, ok := _u.mutation.SSOCert(); ok {
|
|
v.Property(dsl.Single, user.FieldSSOCert, value)
|
|
}
|
|
if value, ok := _u.mutation.FilesCount(); ok {
|
|
v.Property(dsl.Single, user.FieldFilesCount, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedFilesCount(); ok {
|
|
v.Property(dsl.Single, user.FieldFilesCount, __.Union(__.Values(user.FieldFilesCount), __.Constant(value)).Sum())
|
|
}
|
|
var properties []any
|
|
if _u.mutation.OptionalIntCleared() {
|
|
properties = append(properties, user.FieldOptionalInt)
|
|
}
|
|
if _u.mutation.NicknameCleared() {
|
|
properties = append(properties, user.FieldNickname)
|
|
}
|
|
if _u.mutation.AddressCleared() {
|
|
properties = append(properties, user.FieldAddress)
|
|
}
|
|
if _u.mutation.PhoneCleared() {
|
|
properties = append(properties, user.FieldPhone)
|
|
}
|
|
if _u.mutation.PasswordCleared() {
|
|
properties = append(properties, user.FieldPassword)
|
|
}
|
|
if _u.mutation.SSOCertCleared() {
|
|
properties = append(properties, user.FieldSSOCert)
|
|
}
|
|
if _u.mutation.FilesCountCleared() {
|
|
properties = append(properties, user.FieldFilesCount)
|
|
}
|
|
if len(properties) > 0 {
|
|
v.SideEffect(__.Properties(properties...).Drop())
|
|
}
|
|
if _u.mutation.CardCleared() {
|
|
tr := rv.Clone().OutE(user.CardLabel).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.CardIDs() {
|
|
v.AddE(user.CardLabel).To(g.V(id)).OutV()
|
|
constraints = append(constraints, &constraint{
|
|
pred: g.E().HasLabel(user.CardLabel).InV().HasID(id).Count(),
|
|
test: __.Is(p.NEQ(0)).Constant(NewErrUniqueEdge(user.Label, user.CardLabel, id)),
|
|
})
|
|
}
|
|
for _, id := range _u.mutation.RemovedPetsIDs() {
|
|
tr := rv.Clone().OutE(user.PetsLabel).Where(__.OtherV().HasID(id)).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.PetsIDs() {
|
|
v.AddE(user.PetsLabel).To(g.V(id)).OutV()
|
|
constraints = append(constraints, &constraint{
|
|
pred: g.E().HasLabel(user.PetsLabel).InV().HasID(id).Count(),
|
|
test: __.Is(p.NEQ(0)).Constant(NewErrUniqueEdge(user.Label, user.PetsLabel, id)),
|
|
})
|
|
}
|
|
for _, id := range _u.mutation.RemovedFilesIDs() {
|
|
tr := rv.Clone().OutE(user.FilesLabel).Where(__.OtherV().HasID(id)).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.FilesIDs() {
|
|
v.AddE(user.FilesLabel).To(g.V(id)).OutV()
|
|
constraints = append(constraints, &constraint{
|
|
pred: g.E().HasLabel(user.FilesLabel).InV().HasID(id).Count(),
|
|
test: __.Is(p.NEQ(0)).Constant(NewErrUniqueEdge(user.Label, user.FilesLabel, id)),
|
|
})
|
|
}
|
|
for _, id := range _u.mutation.RemovedGroupsIDs() {
|
|
tr := rv.Clone().OutE(user.GroupsLabel).Where(__.OtherV().HasID(id)).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.GroupsIDs() {
|
|
v.AddE(user.GroupsLabel).To(g.V(id)).OutV()
|
|
}
|
|
for _, id := range _u.mutation.RemovedFriendsIDs() {
|
|
tr := rv.Clone().BothE(user.FriendsLabel).Where(__.Or(__.InV().HasID(id), __.OutV().HasID(id))).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.FriendsIDs() {
|
|
v.AddE(user.FriendsLabel).To(g.V(id)).OutV()
|
|
}
|
|
for _, id := range _u.mutation.RemovedFollowersIDs() {
|
|
tr := rv.Clone().InE(user.FollowingLabel).Where(__.OtherV().HasID(id)).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.FollowersIDs() {
|
|
v.AddE(user.FollowingLabel).From(g.V(id)).InV()
|
|
}
|
|
for _, id := range _u.mutation.RemovedFollowingIDs() {
|
|
tr := rv.Clone().OutE(user.FollowingLabel).Where(__.OtherV().HasID(id)).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.FollowingIDs() {
|
|
v.AddE(user.FollowingLabel).To(g.V(id)).OutV()
|
|
}
|
|
if _u.mutation.TeamCleared() {
|
|
tr := rv.Clone().OutE(user.TeamLabel).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.TeamIDs() {
|
|
v.AddE(user.TeamLabel).To(g.V(id)).OutV()
|
|
constraints = append(constraints, &constraint{
|
|
pred: g.E().HasLabel(user.TeamLabel).InV().HasID(id).Count(),
|
|
test: __.Is(p.NEQ(0)).Constant(NewErrUniqueEdge(user.Label, user.TeamLabel, id)),
|
|
})
|
|
}
|
|
if _u.mutation.SpouseCleared() {
|
|
tr := rv.Clone().BothE(user.SpouseLabel).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.SpouseIDs() {
|
|
v.AddE(user.SpouseLabel).To(g.V(id)).OutV()
|
|
constraints = append(constraints, &constraint{
|
|
pred: rv.Clone().Both(user.SpouseLabel).Count(),
|
|
test: __.Is(p.NEQ(0)).Constant(NewErrUniqueEdge(user.Label, user.SpouseLabel, id)),
|
|
})
|
|
constraints = append(constraints, &constraint{
|
|
pred: g.E().HasLabel(user.SpouseLabel).Where(__.Or(__.InV().HasID(id), __.OutV().HasID(id))).Count(),
|
|
test: __.Is(p.NEQ(0)).Constant(NewErrUniqueEdge(user.Label, user.SpouseLabel, id)),
|
|
})
|
|
}
|
|
for _, id := range _u.mutation.RemovedChildrenIDs() {
|
|
tr := rv.Clone().InE(user.ParentLabel).Where(__.OtherV().HasID(id)).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.ChildrenIDs() {
|
|
v.AddE(user.ParentLabel).From(g.V(id)).InV()
|
|
constraints = append(constraints, &constraint{
|
|
pred: g.E().HasLabel(user.ParentLabel).OutV().HasID(id).Count(),
|
|
test: __.Is(p.NEQ(0)).Constant(NewErrUniqueEdge(user.Label, user.ParentLabel, id)),
|
|
})
|
|
}
|
|
if _u.mutation.ParentCleared() {
|
|
tr := rv.Clone().OutE(user.ParentLabel).Drop().Iterate()
|
|
trs = append(trs, tr)
|
|
}
|
|
for _, id := range _u.mutation.ParentIDs() {
|
|
v.AddE(user.ParentLabel).To(g.V(id)).OutV()
|
|
}
|
|
if len(_u.fields) > 0 {
|
|
fields := make([]any, 0, len(_u.fields)+1)
|
|
fields = append(fields, true)
|
|
for _, f := range _u.fields {
|
|
fields = append(fields, f)
|
|
}
|
|
v.ValueMap(fields...)
|
|
} else {
|
|
v.ValueMap(true)
|
|
}
|
|
if len(constraints) > 0 {
|
|
v = constraints[0].pred.Coalesce(constraints[0].test, v)
|
|
for _, cr := range constraints[1:] {
|
|
v = cr.pred.Coalesce(cr.test, v)
|
|
}
|
|
}
|
|
trs = append(trs, v)
|
|
return dsl.Join(trs...)
|
|
}
|