// Code generated by ent, DO NOT EDIT.

package ent

import (
	"context"
	"errors"
	"fmt"
	"time"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
	"github.com/member-gentei/member-gentei/gentei/ent/guild"
	"github.com/member-gentei/member-gentei/gentei/ent/guildrole"
	"github.com/member-gentei/member-gentei/gentei/ent/predicate"
	"github.com/member-gentei/member-gentei/gentei/ent/usermembership"
	"github.com/member-gentei/member-gentei/gentei/ent/youtubetalent"
)

// GuildRoleUpdate is the builder for updating GuildRole entities.
type GuildRoleUpdate struct {
	config
	hooks    []Hook
	mutation *GuildRoleMutation
}

// Where appends a list predicates to the GuildRoleUpdate builder.
func (gru *GuildRoleUpdate) Where(ps ...predicate.GuildRole) *GuildRoleUpdate {
	gru.mutation.Where(ps...)
	return gru
}

// SetName sets the "name" field.
func (gru *GuildRoleUpdate) SetName(s string) *GuildRoleUpdate {
	gru.mutation.SetName(s)
	return gru
}

// SetNillableName sets the "name" field if the given value is not nil.
func (gru *GuildRoleUpdate) SetNillableName(s *string) *GuildRoleUpdate {
	if s != nil {
		gru.SetName(*s)
	}
	return gru
}

// SetLastUpdated sets the "last_updated" field.
func (gru *GuildRoleUpdate) SetLastUpdated(t time.Time) *GuildRoleUpdate {
	gru.mutation.SetLastUpdated(t)
	return gru
}

// SetNillableLastUpdated sets the "last_updated" field if the given value is not nil.
func (gru *GuildRoleUpdate) SetNillableLastUpdated(t *time.Time) *GuildRoleUpdate {
	if t != nil {
		gru.SetLastUpdated(*t)
	}
	return gru
}

// SetGuildID sets the "guild" edge to the Guild entity by ID.
func (gru *GuildRoleUpdate) SetGuildID(id uint64) *GuildRoleUpdate {
	gru.mutation.SetGuildID(id)
	return gru
}

// SetGuild sets the "guild" edge to the Guild entity.
func (gru *GuildRoleUpdate) SetGuild(g *Guild) *GuildRoleUpdate {
	return gru.SetGuildID(g.ID)
}

// AddUserMembershipIDs adds the "user_memberships" edge to the UserMembership entity by IDs.
func (gru *GuildRoleUpdate) AddUserMembershipIDs(ids ...int) *GuildRoleUpdate {
	gru.mutation.AddUserMembershipIDs(ids...)
	return gru
}

// AddUserMemberships adds the "user_memberships" edges to the UserMembership entity.
func (gru *GuildRoleUpdate) AddUserMemberships(u ...*UserMembership) *GuildRoleUpdate {
	ids := make([]int, len(u))
	for i := range u {
		ids[i] = u[i].ID
	}
	return gru.AddUserMembershipIDs(ids...)
}

// SetTalentID sets the "talent" edge to the YouTubeTalent entity by ID.
func (gru *GuildRoleUpdate) SetTalentID(id string) *GuildRoleUpdate {
	gru.mutation.SetTalentID(id)
	return gru
}

// SetNillableTalentID sets the "talent" edge to the YouTubeTalent entity by ID if the given value is not nil.
func (gru *GuildRoleUpdate) SetNillableTalentID(id *string) *GuildRoleUpdate {
	if id != nil {
		gru = gru.SetTalentID(*id)
	}
	return gru
}

// SetTalent sets the "talent" edge to the YouTubeTalent entity.
func (gru *GuildRoleUpdate) SetTalent(y *YouTubeTalent) *GuildRoleUpdate {
	return gru.SetTalentID(y.ID)
}

// Mutation returns the GuildRoleMutation object of the builder.
func (gru *GuildRoleUpdate) Mutation() *GuildRoleMutation {
	return gru.mutation
}

// ClearGuild clears the "guild" edge to the Guild entity.
func (gru *GuildRoleUpdate) ClearGuild() *GuildRoleUpdate {
	gru.mutation.ClearGuild()
	return gru
}

// ClearUserMemberships clears all "user_memberships" edges to the UserMembership entity.
func (gru *GuildRoleUpdate) ClearUserMemberships() *GuildRoleUpdate {
	gru.mutation.ClearUserMemberships()
	return gru
}

// RemoveUserMembershipIDs removes the "user_memberships" edge to UserMembership entities by IDs.
func (gru *GuildRoleUpdate) RemoveUserMembershipIDs(ids ...int) *GuildRoleUpdate {
	gru.mutation.RemoveUserMembershipIDs(ids...)
	return gru
}

// RemoveUserMemberships removes "user_memberships" edges to UserMembership entities.
func (gru *GuildRoleUpdate) RemoveUserMemberships(u ...*UserMembership) *GuildRoleUpdate {
	ids := make([]int, len(u))
	for i := range u {
		ids[i] = u[i].ID
	}
	return gru.RemoveUserMembershipIDs(ids...)
}

// ClearTalent clears the "talent" edge to the YouTubeTalent entity.
func (gru *GuildRoleUpdate) ClearTalent() *GuildRoleUpdate {
	gru.mutation.ClearTalent()
	return gru
}

// Save executes the query and returns the number of nodes affected by the update operation.
func (gru *GuildRoleUpdate) Save(ctx context.Context) (int, error) {
	return withHooks(ctx, gru.sqlSave, gru.mutation, gru.hooks)
}

// SaveX is like Save, but panics if an error occurs.
func (gru *GuildRoleUpdate) SaveX(ctx context.Context) int {
	affected, err := gru.Save(ctx)
	if err != nil {
		panic(err)
	}
	return affected
}

// Exec executes the query.
func (gru *GuildRoleUpdate) Exec(ctx context.Context) error {
	_, err := gru.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (gru *GuildRoleUpdate) ExecX(ctx context.Context) {
	if err := gru.Exec(ctx); err != nil {
		panic(err)
	}
}

// check runs all checks and user-defined validators on the builder.
func (gru *GuildRoleUpdate) check() error {
	if gru.mutation.GuildCleared() && len(gru.mutation.GuildIDs()) > 0 {
		return errors.New(`ent: clearing a required unique edge "GuildRole.guild"`)
	}
	return nil
}

func (gru *GuildRoleUpdate) sqlSave(ctx context.Context) (n int, err error) {
	if err := gru.check(); err != nil {
		return n, err
	}
	_spec := sqlgraph.NewUpdateSpec(guildrole.Table, guildrole.Columns, sqlgraph.NewFieldSpec(guildrole.FieldID, field.TypeUint64))
	if ps := gru.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := gru.mutation.Name(); ok {
		_spec.SetField(guildrole.FieldName, field.TypeString, value)
	}
	if value, ok := gru.mutation.LastUpdated(); ok {
		_spec.SetField(guildrole.FieldLastUpdated, field.TypeTime, value)
	}
	if gru.mutation.GuildCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   guildrole.GuildTable,
			Columns: []string{guildrole.GuildColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(guild.FieldID, field.TypeUint64),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := gru.mutation.GuildIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   guildrole.GuildTable,
			Columns: []string{guildrole.GuildColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(guild.FieldID, field.TypeUint64),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if gru.mutation.UserMembershipsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: true,
			Table:   guildrole.UserMembershipsTable,
			Columns: guildrole.UserMembershipsPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(usermembership.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := gru.mutation.RemovedUserMembershipsIDs(); len(nodes) > 0 && !gru.mutation.UserMembershipsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: true,
			Table:   guildrole.UserMembershipsTable,
			Columns: guildrole.UserMembershipsPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(usermembership.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 := gru.mutation.UserMembershipsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: true,
			Table:   guildrole.UserMembershipsTable,
			Columns: guildrole.UserMembershipsPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(usermembership.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if gru.mutation.TalentCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   guildrole.TalentTable,
			Columns: []string{guildrole.TalentColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(youtubetalent.FieldID, field.TypeString),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := gru.mutation.TalentIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   guildrole.TalentTable,
			Columns: []string{guildrole.TalentColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(youtubetalent.FieldID, field.TypeString),
			},
		}
		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, gru.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{guildrole.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return 0, err
	}
	gru.mutation.done = true
	return n, nil
}

// GuildRoleUpdateOne is the builder for updating a single GuildRole entity.
type GuildRoleUpdateOne struct {
	config
	fields   []string
	hooks    []Hook
	mutation *GuildRoleMutation
}

// SetName sets the "name" field.
func (gruo *GuildRoleUpdateOne) SetName(s string) *GuildRoleUpdateOne {
	gruo.mutation.SetName(s)
	return gruo
}

// SetNillableName sets the "name" field if the given value is not nil.
func (gruo *GuildRoleUpdateOne) SetNillableName(s *string) *GuildRoleUpdateOne {
	if s != nil {
		gruo.SetName(*s)
	}
	return gruo
}

// SetLastUpdated sets the "last_updated" field.
func (gruo *GuildRoleUpdateOne) SetLastUpdated(t time.Time) *GuildRoleUpdateOne {
	gruo.mutation.SetLastUpdated(t)
	return gruo
}

// SetNillableLastUpdated sets the "last_updated" field if the given value is not nil.
func (gruo *GuildRoleUpdateOne) SetNillableLastUpdated(t *time.Time) *GuildRoleUpdateOne {
	if t != nil {
		gruo.SetLastUpdated(*t)
	}
	return gruo
}

// SetGuildID sets the "guild" edge to the Guild entity by ID.
func (gruo *GuildRoleUpdateOne) SetGuildID(id uint64) *GuildRoleUpdateOne {
	gruo.mutation.SetGuildID(id)
	return gruo
}

// SetGuild sets the "guild" edge to the Guild entity.
func (gruo *GuildRoleUpdateOne) SetGuild(g *Guild) *GuildRoleUpdateOne {
	return gruo.SetGuildID(g.ID)
}

// AddUserMembershipIDs adds the "user_memberships" edge to the UserMembership entity by IDs.
func (gruo *GuildRoleUpdateOne) AddUserMembershipIDs(ids ...int) *GuildRoleUpdateOne {
	gruo.mutation.AddUserMembershipIDs(ids...)
	return gruo
}

// AddUserMemberships adds the "user_memberships" edges to the UserMembership entity.
func (gruo *GuildRoleUpdateOne) AddUserMemberships(u ...*UserMembership) *GuildRoleUpdateOne {
	ids := make([]int, len(u))
	for i := range u {
		ids[i] = u[i].ID
	}
	return gruo.AddUserMembershipIDs(ids...)
}

// SetTalentID sets the "talent" edge to the YouTubeTalent entity by ID.
func (gruo *GuildRoleUpdateOne) SetTalentID(id string) *GuildRoleUpdateOne {
	gruo.mutation.SetTalentID(id)
	return gruo
}

// SetNillableTalentID sets the "talent" edge to the YouTubeTalent entity by ID if the given value is not nil.
func (gruo *GuildRoleUpdateOne) SetNillableTalentID(id *string) *GuildRoleUpdateOne {
	if id != nil {
		gruo = gruo.SetTalentID(*id)
	}
	return gruo
}

// SetTalent sets the "talent" edge to the YouTubeTalent entity.
func (gruo *GuildRoleUpdateOne) SetTalent(y *YouTubeTalent) *GuildRoleUpdateOne {
	return gruo.SetTalentID(y.ID)
}

// Mutation returns the GuildRoleMutation object of the builder.
func (gruo *GuildRoleUpdateOne) Mutation() *GuildRoleMutation {
	return gruo.mutation
}

// ClearGuild clears the "guild" edge to the Guild entity.
func (gruo *GuildRoleUpdateOne) ClearGuild() *GuildRoleUpdateOne {
	gruo.mutation.ClearGuild()
	return gruo
}

// ClearUserMemberships clears all "user_memberships" edges to the UserMembership entity.
func (gruo *GuildRoleUpdateOne) ClearUserMemberships() *GuildRoleUpdateOne {
	gruo.mutation.ClearUserMemberships()
	return gruo
}

// RemoveUserMembershipIDs removes the "user_memberships" edge to UserMembership entities by IDs.
func (gruo *GuildRoleUpdateOne) RemoveUserMembershipIDs(ids ...int) *GuildRoleUpdateOne {
	gruo.mutation.RemoveUserMembershipIDs(ids...)
	return gruo
}

// RemoveUserMemberships removes "user_memberships" edges to UserMembership entities.
func (gruo *GuildRoleUpdateOne) RemoveUserMemberships(u ...*UserMembership) *GuildRoleUpdateOne {
	ids := make([]int, len(u))
	for i := range u {
		ids[i] = u[i].ID
	}
	return gruo.RemoveUserMembershipIDs(ids...)
}

// ClearTalent clears the "talent" edge to the YouTubeTalent entity.
func (gruo *GuildRoleUpdateOne) ClearTalent() *GuildRoleUpdateOne {
	gruo.mutation.ClearTalent()
	return gruo
}

// Where appends a list predicates to the GuildRoleUpdate builder.
func (gruo *GuildRoleUpdateOne) Where(ps ...predicate.GuildRole) *GuildRoleUpdateOne {
	gruo.mutation.Where(ps...)
	return gruo
}

// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (gruo *GuildRoleUpdateOne) Select(field string, fields ...string) *GuildRoleUpdateOne {
	gruo.fields = append([]string{field}, fields...)
	return gruo
}

// Save executes the query and returns the updated GuildRole entity.
func (gruo *GuildRoleUpdateOne) Save(ctx context.Context) (*GuildRole, error) {
	return withHooks(ctx, gruo.sqlSave, gruo.mutation, gruo.hooks)
}

// SaveX is like Save, but panics if an error occurs.
func (gruo *GuildRoleUpdateOne) SaveX(ctx context.Context) *GuildRole {
	node, err := gruo.Save(ctx)
	if err != nil {
		panic(err)
	}
	return node
}

// Exec executes the query on the entity.
func (gruo *GuildRoleUpdateOne) Exec(ctx context.Context) error {
	_, err := gruo.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (gruo *GuildRoleUpdateOne) ExecX(ctx context.Context) {
	if err := gruo.Exec(ctx); err != nil {
		panic(err)
	}
}

// check runs all checks and user-defined validators on the builder.
func (gruo *GuildRoleUpdateOne) check() error {
	if gruo.mutation.GuildCleared() && len(gruo.mutation.GuildIDs()) > 0 {
		return errors.New(`ent: clearing a required unique edge "GuildRole.guild"`)
	}
	return nil
}

func (gruo *GuildRoleUpdateOne) sqlSave(ctx context.Context) (_node *GuildRole, err error) {
	if err := gruo.check(); err != nil {
		return _node, err
	}
	_spec := sqlgraph.NewUpdateSpec(guildrole.Table, guildrole.Columns, sqlgraph.NewFieldSpec(guildrole.FieldID, field.TypeUint64))
	id, ok := gruo.mutation.ID()
	if !ok {
		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "GuildRole.id" for update`)}
	}
	_spec.Node.ID.Value = id
	if fields := gruo.fields; len(fields) > 0 {
		_spec.Node.Columns = make([]string, 0, len(fields))
		_spec.Node.Columns = append(_spec.Node.Columns, guildrole.FieldID)
		for _, f := range fields {
			if !guildrole.ValidColumn(f) {
				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
			}
			if f != guildrole.FieldID {
				_spec.Node.Columns = append(_spec.Node.Columns, f)
			}
		}
	}
	if ps := gruo.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := gruo.mutation.Name(); ok {
		_spec.SetField(guildrole.FieldName, field.TypeString, value)
	}
	if value, ok := gruo.mutation.LastUpdated(); ok {
		_spec.SetField(guildrole.FieldLastUpdated, field.TypeTime, value)
	}
	if gruo.mutation.GuildCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   guildrole.GuildTable,
			Columns: []string{guildrole.GuildColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(guild.FieldID, field.TypeUint64),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := gruo.mutation.GuildIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   guildrole.GuildTable,
			Columns: []string{guildrole.GuildColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(guild.FieldID, field.TypeUint64),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if gruo.mutation.UserMembershipsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: true,
			Table:   guildrole.UserMembershipsTable,
			Columns: guildrole.UserMembershipsPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(usermembership.FieldID, field.TypeInt),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := gruo.mutation.RemovedUserMembershipsIDs(); len(nodes) > 0 && !gruo.mutation.UserMembershipsCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: true,
			Table:   guildrole.UserMembershipsTable,
			Columns: guildrole.UserMembershipsPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(usermembership.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 := gruo.mutation.UserMembershipsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2M,
			Inverse: true,
			Table:   guildrole.UserMembershipsTable,
			Columns: guildrole.UserMembershipsPrimaryKey,
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(usermembership.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	if gruo.mutation.TalentCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   guildrole.TalentTable,
			Columns: []string{guildrole.TalentColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(youtubetalent.FieldID, field.TypeString),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := gruo.mutation.TalentIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   guildrole.TalentTable,
			Columns: []string{guildrole.TalentColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(youtubetalent.FieldID, field.TypeString),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	_node = &GuildRole{config: gruo.config}
	_spec.Assign = _node.assignValues
	_spec.ScanValues = _node.scanValues
	if err = sqlgraph.UpdateNode(ctx, gruo.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{guildrole.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return nil, err
	}
	gruo.mutation.done = true
	return _node, nil
}
