635 lines
19 KiB
Go
635 lines
19 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"tinyskin/db/ent/predicate"
|
|
"tinyskin/db/ent/texture"
|
|
"tinyskin/db/ent/user"
|
|
"tinyskin/db/ent/userprofile"
|
|
"tinyskin/db/ent/usertexture"
|
|
)
|
|
|
|
// TextureUpdate is the builder for updating Texture entities.
|
|
type TextureUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *TextureMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the TextureUpdate builder.
|
|
func (tu *TextureUpdate) Where(ps ...predicate.Texture) *TextureUpdate {
|
|
tu.mutation.Where(ps...)
|
|
return tu
|
|
}
|
|
|
|
// SetTextureHash sets the "texture_hash" field.
|
|
func (tu *TextureUpdate) SetTextureHash(s string) *TextureUpdate {
|
|
tu.mutation.SetTextureHash(s)
|
|
return tu
|
|
}
|
|
|
|
// SetCreatedUserID sets the "created_user" edge to the User entity by ID.
|
|
func (tu *TextureUpdate) SetCreatedUserID(id int) *TextureUpdate {
|
|
tu.mutation.SetCreatedUserID(id)
|
|
return tu
|
|
}
|
|
|
|
// SetCreatedUser sets the "created_user" edge to the User entity.
|
|
func (tu *TextureUpdate) SetCreatedUser(u *User) *TextureUpdate {
|
|
return tu.SetCreatedUserID(u.ID)
|
|
}
|
|
|
|
// AddUserProfileIDs adds the "user_profile" edge to the UserProfile entity by IDs.
|
|
func (tu *TextureUpdate) AddUserProfileIDs(ids ...int) *TextureUpdate {
|
|
tu.mutation.AddUserProfileIDs(ids...)
|
|
return tu
|
|
}
|
|
|
|
// AddUserProfile adds the "user_profile" edges to the UserProfile entity.
|
|
func (tu *TextureUpdate) AddUserProfile(u ...*UserProfile) *TextureUpdate {
|
|
ids := make([]int, len(u))
|
|
for i := range u {
|
|
ids[i] = u[i].ID
|
|
}
|
|
return tu.AddUserProfileIDs(ids...)
|
|
}
|
|
|
|
// AddUsertextureIDs adds the "usertexture" edge to the UserTexture entity by IDs.
|
|
func (tu *TextureUpdate) AddUsertextureIDs(ids ...int) *TextureUpdate {
|
|
tu.mutation.AddUsertextureIDs(ids...)
|
|
return tu
|
|
}
|
|
|
|
// AddUsertexture adds the "usertexture" edges to the UserTexture entity.
|
|
func (tu *TextureUpdate) AddUsertexture(u ...*UserTexture) *TextureUpdate {
|
|
ids := make([]int, len(u))
|
|
for i := range u {
|
|
ids[i] = u[i].ID
|
|
}
|
|
return tu.AddUsertextureIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the TextureMutation object of the builder.
|
|
func (tu *TextureUpdate) Mutation() *TextureMutation {
|
|
return tu.mutation
|
|
}
|
|
|
|
// ClearCreatedUser clears the "created_user" edge to the User entity.
|
|
func (tu *TextureUpdate) ClearCreatedUser() *TextureUpdate {
|
|
tu.mutation.ClearCreatedUser()
|
|
return tu
|
|
}
|
|
|
|
// ClearUserProfile clears all "user_profile" edges to the UserProfile entity.
|
|
func (tu *TextureUpdate) ClearUserProfile() *TextureUpdate {
|
|
tu.mutation.ClearUserProfile()
|
|
return tu
|
|
}
|
|
|
|
// RemoveUserProfileIDs removes the "user_profile" edge to UserProfile entities by IDs.
|
|
func (tu *TextureUpdate) RemoveUserProfileIDs(ids ...int) *TextureUpdate {
|
|
tu.mutation.RemoveUserProfileIDs(ids...)
|
|
return tu
|
|
}
|
|
|
|
// RemoveUserProfile removes "user_profile" edges to UserProfile entities.
|
|
func (tu *TextureUpdate) RemoveUserProfile(u ...*UserProfile) *TextureUpdate {
|
|
ids := make([]int, len(u))
|
|
for i := range u {
|
|
ids[i] = u[i].ID
|
|
}
|
|
return tu.RemoveUserProfileIDs(ids...)
|
|
}
|
|
|
|
// ClearUsertexture clears all "usertexture" edges to the UserTexture entity.
|
|
func (tu *TextureUpdate) ClearUsertexture() *TextureUpdate {
|
|
tu.mutation.ClearUsertexture()
|
|
return tu
|
|
}
|
|
|
|
// RemoveUsertextureIDs removes the "usertexture" edge to UserTexture entities by IDs.
|
|
func (tu *TextureUpdate) RemoveUsertextureIDs(ids ...int) *TextureUpdate {
|
|
tu.mutation.RemoveUsertextureIDs(ids...)
|
|
return tu
|
|
}
|
|
|
|
// RemoveUsertexture removes "usertexture" edges to UserTexture entities.
|
|
func (tu *TextureUpdate) RemoveUsertexture(u ...*UserTexture) *TextureUpdate {
|
|
ids := make([]int, len(u))
|
|
for i := range u {
|
|
ids[i] = u[i].ID
|
|
}
|
|
return tu.RemoveUsertextureIDs(ids...)
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (tu *TextureUpdate) Save(ctx context.Context) (int, error) {
|
|
return withHooks(ctx, tu.sqlSave, tu.mutation, tu.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (tu *TextureUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := tu.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (tu *TextureUpdate) Exec(ctx context.Context) error {
|
|
_, err := tu.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (tu *TextureUpdate) ExecX(ctx context.Context) {
|
|
if err := tu.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (tu *TextureUpdate) check() error {
|
|
if _, ok := tu.mutation.CreatedUserID(); tu.mutation.CreatedUserCleared() && !ok {
|
|
return errors.New(`ent: clearing a required unique edge "Texture.created_user"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (tu *TextureUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|
if err := tu.check(); err != nil {
|
|
return n, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(texture.Table, texture.Columns, sqlgraph.NewFieldSpec(texture.FieldID, field.TypeInt))
|
|
if ps := tu.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := tu.mutation.TextureHash(); ok {
|
|
_spec.SetField(texture.FieldTextureHash, field.TypeString, value)
|
|
}
|
|
if tu.mutation.CreatedUserCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: texture.CreatedUserTable,
|
|
Columns: []string{texture.CreatedUserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := tu.mutation.CreatedUserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: texture.CreatedUserTable,
|
|
Columns: []string{texture.CreatedUserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if tu.mutation.UserProfileCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: false,
|
|
Table: texture.UserProfileTable,
|
|
Columns: texture.UserProfilePrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(userprofile.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := tu.mutation.RemovedUserProfileIDs(); len(nodes) > 0 && !tu.mutation.UserProfileCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: false,
|
|
Table: texture.UserProfileTable,
|
|
Columns: texture.UserProfilePrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(userprofile.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := tu.mutation.UserProfileIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: false,
|
|
Table: texture.UserProfileTable,
|
|
Columns: texture.UserProfilePrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(userprofile.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if tu.mutation.UsertextureCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
Table: texture.UsertextureTable,
|
|
Columns: []string{texture.UsertextureColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(usertexture.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := tu.mutation.RemovedUsertextureIDs(); len(nodes) > 0 && !tu.mutation.UsertextureCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
Table: texture.UsertextureTable,
|
|
Columns: []string{texture.UsertextureColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(usertexture.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := tu.mutation.UsertextureIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
Table: texture.UsertextureTable,
|
|
Columns: []string{texture.UsertextureColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(usertexture.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if n, err = sqlgraph.UpdateNodes(ctx, tu.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{texture.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
tu.mutation.done = true
|
|
return n, nil
|
|
}
|
|
|
|
// TextureUpdateOne is the builder for updating a single Texture entity.
|
|
type TextureUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *TextureMutation
|
|
}
|
|
|
|
// SetTextureHash sets the "texture_hash" field.
|
|
func (tuo *TextureUpdateOne) SetTextureHash(s string) *TextureUpdateOne {
|
|
tuo.mutation.SetTextureHash(s)
|
|
return tuo
|
|
}
|
|
|
|
// SetCreatedUserID sets the "created_user" edge to the User entity by ID.
|
|
func (tuo *TextureUpdateOne) SetCreatedUserID(id int) *TextureUpdateOne {
|
|
tuo.mutation.SetCreatedUserID(id)
|
|
return tuo
|
|
}
|
|
|
|
// SetCreatedUser sets the "created_user" edge to the User entity.
|
|
func (tuo *TextureUpdateOne) SetCreatedUser(u *User) *TextureUpdateOne {
|
|
return tuo.SetCreatedUserID(u.ID)
|
|
}
|
|
|
|
// AddUserProfileIDs adds the "user_profile" edge to the UserProfile entity by IDs.
|
|
func (tuo *TextureUpdateOne) AddUserProfileIDs(ids ...int) *TextureUpdateOne {
|
|
tuo.mutation.AddUserProfileIDs(ids...)
|
|
return tuo
|
|
}
|
|
|
|
// AddUserProfile adds the "user_profile" edges to the UserProfile entity.
|
|
func (tuo *TextureUpdateOne) AddUserProfile(u ...*UserProfile) *TextureUpdateOne {
|
|
ids := make([]int, len(u))
|
|
for i := range u {
|
|
ids[i] = u[i].ID
|
|
}
|
|
return tuo.AddUserProfileIDs(ids...)
|
|
}
|
|
|
|
// AddUsertextureIDs adds the "usertexture" edge to the UserTexture entity by IDs.
|
|
func (tuo *TextureUpdateOne) AddUsertextureIDs(ids ...int) *TextureUpdateOne {
|
|
tuo.mutation.AddUsertextureIDs(ids...)
|
|
return tuo
|
|
}
|
|
|
|
// AddUsertexture adds the "usertexture" edges to the UserTexture entity.
|
|
func (tuo *TextureUpdateOne) AddUsertexture(u ...*UserTexture) *TextureUpdateOne {
|
|
ids := make([]int, len(u))
|
|
for i := range u {
|
|
ids[i] = u[i].ID
|
|
}
|
|
return tuo.AddUsertextureIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the TextureMutation object of the builder.
|
|
func (tuo *TextureUpdateOne) Mutation() *TextureMutation {
|
|
return tuo.mutation
|
|
}
|
|
|
|
// ClearCreatedUser clears the "created_user" edge to the User entity.
|
|
func (tuo *TextureUpdateOne) ClearCreatedUser() *TextureUpdateOne {
|
|
tuo.mutation.ClearCreatedUser()
|
|
return tuo
|
|
}
|
|
|
|
// ClearUserProfile clears all "user_profile" edges to the UserProfile entity.
|
|
func (tuo *TextureUpdateOne) ClearUserProfile() *TextureUpdateOne {
|
|
tuo.mutation.ClearUserProfile()
|
|
return tuo
|
|
}
|
|
|
|
// RemoveUserProfileIDs removes the "user_profile" edge to UserProfile entities by IDs.
|
|
func (tuo *TextureUpdateOne) RemoveUserProfileIDs(ids ...int) *TextureUpdateOne {
|
|
tuo.mutation.RemoveUserProfileIDs(ids...)
|
|
return tuo
|
|
}
|
|
|
|
// RemoveUserProfile removes "user_profile" edges to UserProfile entities.
|
|
func (tuo *TextureUpdateOne) RemoveUserProfile(u ...*UserProfile) *TextureUpdateOne {
|
|
ids := make([]int, len(u))
|
|
for i := range u {
|
|
ids[i] = u[i].ID
|
|
}
|
|
return tuo.RemoveUserProfileIDs(ids...)
|
|
}
|
|
|
|
// ClearUsertexture clears all "usertexture" edges to the UserTexture entity.
|
|
func (tuo *TextureUpdateOne) ClearUsertexture() *TextureUpdateOne {
|
|
tuo.mutation.ClearUsertexture()
|
|
return tuo
|
|
}
|
|
|
|
// RemoveUsertextureIDs removes the "usertexture" edge to UserTexture entities by IDs.
|
|
func (tuo *TextureUpdateOne) RemoveUsertextureIDs(ids ...int) *TextureUpdateOne {
|
|
tuo.mutation.RemoveUsertextureIDs(ids...)
|
|
return tuo
|
|
}
|
|
|
|
// RemoveUsertexture removes "usertexture" edges to UserTexture entities.
|
|
func (tuo *TextureUpdateOne) RemoveUsertexture(u ...*UserTexture) *TextureUpdateOne {
|
|
ids := make([]int, len(u))
|
|
for i := range u {
|
|
ids[i] = u[i].ID
|
|
}
|
|
return tuo.RemoveUsertextureIDs(ids...)
|
|
}
|
|
|
|
// Where appends a list predicates to the TextureUpdate builder.
|
|
func (tuo *TextureUpdateOne) Where(ps ...predicate.Texture) *TextureUpdateOne {
|
|
tuo.mutation.Where(ps...)
|
|
return tuo
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (tuo *TextureUpdateOne) Select(field string, fields ...string) *TextureUpdateOne {
|
|
tuo.fields = append([]string{field}, fields...)
|
|
return tuo
|
|
}
|
|
|
|
// Save executes the query and returns the updated Texture entity.
|
|
func (tuo *TextureUpdateOne) Save(ctx context.Context) (*Texture, error) {
|
|
return withHooks(ctx, tuo.sqlSave, tuo.mutation, tuo.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (tuo *TextureUpdateOne) SaveX(ctx context.Context) *Texture {
|
|
node, err := tuo.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (tuo *TextureUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := tuo.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (tuo *TextureUpdateOne) ExecX(ctx context.Context) {
|
|
if err := tuo.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (tuo *TextureUpdateOne) check() error {
|
|
if _, ok := tuo.mutation.CreatedUserID(); tuo.mutation.CreatedUserCleared() && !ok {
|
|
return errors.New(`ent: clearing a required unique edge "Texture.created_user"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (tuo *TextureUpdateOne) sqlSave(ctx context.Context) (_node *Texture, err error) {
|
|
if err := tuo.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(texture.Table, texture.Columns, sqlgraph.NewFieldSpec(texture.FieldID, field.TypeInt))
|
|
id, ok := tuo.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Texture.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := tuo.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, texture.FieldID)
|
|
for _, f := range fields {
|
|
if !texture.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != texture.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := tuo.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := tuo.mutation.TextureHash(); ok {
|
|
_spec.SetField(texture.FieldTextureHash, field.TypeString, value)
|
|
}
|
|
if tuo.mutation.CreatedUserCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: texture.CreatedUserTable,
|
|
Columns: []string{texture.CreatedUserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := tuo.mutation.CreatedUserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: texture.CreatedUserTable,
|
|
Columns: []string{texture.CreatedUserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if tuo.mutation.UserProfileCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: false,
|
|
Table: texture.UserProfileTable,
|
|
Columns: texture.UserProfilePrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(userprofile.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := tuo.mutation.RemovedUserProfileIDs(); len(nodes) > 0 && !tuo.mutation.UserProfileCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: false,
|
|
Table: texture.UserProfileTable,
|
|
Columns: texture.UserProfilePrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(userprofile.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := tuo.mutation.UserProfileIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: false,
|
|
Table: texture.UserProfileTable,
|
|
Columns: texture.UserProfilePrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(userprofile.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if tuo.mutation.UsertextureCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
Table: texture.UsertextureTable,
|
|
Columns: []string{texture.UsertextureColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(usertexture.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := tuo.mutation.RemovedUsertextureIDs(); len(nodes) > 0 && !tuo.mutation.UsertextureCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
Table: texture.UsertextureTable,
|
|
Columns: []string{texture.UsertextureColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(usertexture.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := tuo.mutation.UsertextureIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
Table: texture.UsertextureTable,
|
|
Columns: []string{texture.UsertextureColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(usertexture.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_node = &Texture{config: tuo.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, tuo.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{texture.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
tuo.mutation.done = true
|
|
return _node, nil
|
|
}
|