mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-22 19:39:31 +08:00
609 lines
19 KiB
Go
609 lines
19 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/chaitin/MonkeyCode/backend/consts"
|
|
"github.com/chaitin/MonkeyCode/backend/db/predicate"
|
|
"github.com/chaitin/MonkeyCode/backend/db/project"
|
|
"github.com/chaitin/MonkeyCode/backend/db/projectcollaborator"
|
|
"github.com/chaitin/MonkeyCode/backend/db/user"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// ProjectCollaboratorUpdate is the builder for updating ProjectCollaborator entities.
|
|
type ProjectCollaboratorUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *ProjectCollaboratorMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// Where appends a list predicates to the ProjectCollaboratorUpdate builder.
|
|
func (_u *ProjectCollaboratorUpdate) Where(ps ...predicate.ProjectCollaborator) *ProjectCollaboratorUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (_u *ProjectCollaboratorUpdate) SetDeletedAt(v time.Time) *ProjectCollaboratorUpdate {
|
|
_u.mutation.SetDeletedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
func (_u *ProjectCollaboratorUpdate) SetNillableDeletedAt(v *time.Time) *ProjectCollaboratorUpdate {
|
|
if v != nil {
|
|
_u.SetDeletedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (_u *ProjectCollaboratorUpdate) ClearDeletedAt() *ProjectCollaboratorUpdate {
|
|
_u.mutation.ClearDeletedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetProjectID sets the "project_id" field.
|
|
func (_u *ProjectCollaboratorUpdate) SetProjectID(v uuid.UUID) *ProjectCollaboratorUpdate {
|
|
_u.mutation.SetProjectID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableProjectID sets the "project_id" field if the given value is not nil.
|
|
func (_u *ProjectCollaboratorUpdate) SetNillableProjectID(v *uuid.UUID) *ProjectCollaboratorUpdate {
|
|
if v != nil {
|
|
_u.SetProjectID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_u *ProjectCollaboratorUpdate) SetUserID(v uuid.UUID) *ProjectCollaboratorUpdate {
|
|
_u.mutation.SetUserID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
|
func (_u *ProjectCollaboratorUpdate) SetNillableUserID(v *uuid.UUID) *ProjectCollaboratorUpdate {
|
|
if v != nil {
|
|
_u.SetUserID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetRole sets the "role" field.
|
|
func (_u *ProjectCollaboratorUpdate) SetRole(v consts.ProjectCollaboratorRole) *ProjectCollaboratorUpdate {
|
|
_u.mutation.SetRole(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRole sets the "role" field if the given value is not nil.
|
|
func (_u *ProjectCollaboratorUpdate) SetNillableRole(v *consts.ProjectCollaboratorRole) *ProjectCollaboratorUpdate {
|
|
if v != nil {
|
|
_u.SetRole(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *ProjectCollaboratorUpdate) SetCreatedAt(v time.Time) *ProjectCollaboratorUpdate {
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *ProjectCollaboratorUpdate) SetNillableCreatedAt(v *time.Time) *ProjectCollaboratorUpdate {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *ProjectCollaboratorUpdate) SetUpdatedAt(v time.Time) *ProjectCollaboratorUpdate {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetUser sets the "user" edge to the User entity.
|
|
func (_u *ProjectCollaboratorUpdate) SetUser(v *User) *ProjectCollaboratorUpdate {
|
|
return _u.SetUserID(v.ID)
|
|
}
|
|
|
|
// SetProject sets the "project" edge to the Project entity.
|
|
func (_u *ProjectCollaboratorUpdate) SetProject(v *Project) *ProjectCollaboratorUpdate {
|
|
return _u.SetProjectID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the ProjectCollaboratorMutation object of the builder.
|
|
func (_u *ProjectCollaboratorUpdate) Mutation() *ProjectCollaboratorMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearUser clears the "user" edge to the User entity.
|
|
func (_u *ProjectCollaboratorUpdate) ClearUser() *ProjectCollaboratorUpdate {
|
|
_u.mutation.ClearUser()
|
|
return _u
|
|
}
|
|
|
|
// ClearProject clears the "project" edge to the Project entity.
|
|
func (_u *ProjectCollaboratorUpdate) ClearProject() *ProjectCollaboratorUpdate {
|
|
_u.mutation.ClearProject()
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *ProjectCollaboratorUpdate) Save(ctx context.Context) (int, error) {
|
|
if err := _u.defaults(); err != nil {
|
|
return 0, err
|
|
}
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *ProjectCollaboratorUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *ProjectCollaboratorUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *ProjectCollaboratorUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *ProjectCollaboratorUpdate) defaults() error {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
if projectcollaborator.UpdateDefaultUpdatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized projectcollaborator.UpdateDefaultUpdatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := projectcollaborator.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *ProjectCollaboratorUpdate) check() error {
|
|
if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "ProjectCollaborator.user"`)
|
|
}
|
|
if _u.mutation.ProjectCleared() && len(_u.mutation.ProjectIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "ProjectCollaborator.project"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *ProjectCollaboratorUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ProjectCollaboratorUpdate {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *ProjectCollaboratorUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(projectcollaborator.Table, projectcollaborator.Columns, sqlgraph.NewFieldSpec(projectcollaborator.FieldID, field.TypeUUID))
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.DeletedAt(); ok {
|
|
_spec.SetField(projectcollaborator.FieldDeletedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.DeletedAtCleared() {
|
|
_spec.ClearField(projectcollaborator.FieldDeletedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Role(); ok {
|
|
_spec.SetField(projectcollaborator.FieldRole, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(projectcollaborator.FieldCreatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(projectcollaborator.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.UserCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectcollaborator.UserTable,
|
|
Columns: []string{projectcollaborator.UserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.UserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectcollaborator.UserTable,
|
|
Columns: []string{projectcollaborator.UserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.ProjectCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectcollaborator.ProjectTable,
|
|
Columns: []string{projectcollaborator.ProjectColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(project.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.ProjectIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectcollaborator.ProjectTable,
|
|
Columns: []string{projectcollaborator.ProjectColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(project.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{projectcollaborator.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// ProjectCollaboratorUpdateOne is the builder for updating a single ProjectCollaborator entity.
|
|
type ProjectCollaboratorUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *ProjectCollaboratorMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (_u *ProjectCollaboratorUpdateOne) SetDeletedAt(v time.Time) *ProjectCollaboratorUpdateOne {
|
|
_u.mutation.SetDeletedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
func (_u *ProjectCollaboratorUpdateOne) SetNillableDeletedAt(v *time.Time) *ProjectCollaboratorUpdateOne {
|
|
if v != nil {
|
|
_u.SetDeletedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (_u *ProjectCollaboratorUpdateOne) ClearDeletedAt() *ProjectCollaboratorUpdateOne {
|
|
_u.mutation.ClearDeletedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetProjectID sets the "project_id" field.
|
|
func (_u *ProjectCollaboratorUpdateOne) SetProjectID(v uuid.UUID) *ProjectCollaboratorUpdateOne {
|
|
_u.mutation.SetProjectID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableProjectID sets the "project_id" field if the given value is not nil.
|
|
func (_u *ProjectCollaboratorUpdateOne) SetNillableProjectID(v *uuid.UUID) *ProjectCollaboratorUpdateOne {
|
|
if v != nil {
|
|
_u.SetProjectID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_u *ProjectCollaboratorUpdateOne) SetUserID(v uuid.UUID) *ProjectCollaboratorUpdateOne {
|
|
_u.mutation.SetUserID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
|
func (_u *ProjectCollaboratorUpdateOne) SetNillableUserID(v *uuid.UUID) *ProjectCollaboratorUpdateOne {
|
|
if v != nil {
|
|
_u.SetUserID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetRole sets the "role" field.
|
|
func (_u *ProjectCollaboratorUpdateOne) SetRole(v consts.ProjectCollaboratorRole) *ProjectCollaboratorUpdateOne {
|
|
_u.mutation.SetRole(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRole sets the "role" field if the given value is not nil.
|
|
func (_u *ProjectCollaboratorUpdateOne) SetNillableRole(v *consts.ProjectCollaboratorRole) *ProjectCollaboratorUpdateOne {
|
|
if v != nil {
|
|
_u.SetRole(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *ProjectCollaboratorUpdateOne) SetCreatedAt(v time.Time) *ProjectCollaboratorUpdateOne {
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *ProjectCollaboratorUpdateOne) SetNillableCreatedAt(v *time.Time) *ProjectCollaboratorUpdateOne {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *ProjectCollaboratorUpdateOne) SetUpdatedAt(v time.Time) *ProjectCollaboratorUpdateOne {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetUser sets the "user" edge to the User entity.
|
|
func (_u *ProjectCollaboratorUpdateOne) SetUser(v *User) *ProjectCollaboratorUpdateOne {
|
|
return _u.SetUserID(v.ID)
|
|
}
|
|
|
|
// SetProject sets the "project" edge to the Project entity.
|
|
func (_u *ProjectCollaboratorUpdateOne) SetProject(v *Project) *ProjectCollaboratorUpdateOne {
|
|
return _u.SetProjectID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the ProjectCollaboratorMutation object of the builder.
|
|
func (_u *ProjectCollaboratorUpdateOne) Mutation() *ProjectCollaboratorMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearUser clears the "user" edge to the User entity.
|
|
func (_u *ProjectCollaboratorUpdateOne) ClearUser() *ProjectCollaboratorUpdateOne {
|
|
_u.mutation.ClearUser()
|
|
return _u
|
|
}
|
|
|
|
// ClearProject clears the "project" edge to the Project entity.
|
|
func (_u *ProjectCollaboratorUpdateOne) ClearProject() *ProjectCollaboratorUpdateOne {
|
|
_u.mutation.ClearProject()
|
|
return _u
|
|
}
|
|
|
|
// Where appends a list predicates to the ProjectCollaboratorUpdate builder.
|
|
func (_u *ProjectCollaboratorUpdateOne) Where(ps ...predicate.ProjectCollaborator) *ProjectCollaboratorUpdateOne {
|
|
_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 *ProjectCollaboratorUpdateOne) Select(field string, fields ...string) *ProjectCollaboratorUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated ProjectCollaborator entity.
|
|
func (_u *ProjectCollaboratorUpdateOne) Save(ctx context.Context) (*ProjectCollaborator, error) {
|
|
if err := _u.defaults(); err != nil {
|
|
return nil, err
|
|
}
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *ProjectCollaboratorUpdateOne) SaveX(ctx context.Context) *ProjectCollaborator {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *ProjectCollaboratorUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *ProjectCollaboratorUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *ProjectCollaboratorUpdateOne) defaults() error {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
if projectcollaborator.UpdateDefaultUpdatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized projectcollaborator.UpdateDefaultUpdatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := projectcollaborator.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *ProjectCollaboratorUpdateOne) check() error {
|
|
if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "ProjectCollaborator.user"`)
|
|
}
|
|
if _u.mutation.ProjectCleared() && len(_u.mutation.ProjectIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "ProjectCollaborator.project"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *ProjectCollaboratorUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ProjectCollaboratorUpdateOne {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *ProjectCollaboratorUpdateOne) sqlSave(ctx context.Context) (_node *ProjectCollaborator, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(projectcollaborator.Table, projectcollaborator.Columns, sqlgraph.NewFieldSpec(projectcollaborator.FieldID, field.TypeUUID))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "ProjectCollaborator.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := _u.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, projectcollaborator.FieldID)
|
|
for _, f := range fields {
|
|
if !projectcollaborator.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)}
|
|
}
|
|
if f != projectcollaborator.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.DeletedAt(); ok {
|
|
_spec.SetField(projectcollaborator.FieldDeletedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.DeletedAtCleared() {
|
|
_spec.ClearField(projectcollaborator.FieldDeletedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Role(); ok {
|
|
_spec.SetField(projectcollaborator.FieldRole, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(projectcollaborator.FieldCreatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(projectcollaborator.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.UserCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectcollaborator.UserTable,
|
|
Columns: []string{projectcollaborator.UserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.UserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectcollaborator.UserTable,
|
|
Columns: []string{projectcollaborator.UserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.ProjectCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectcollaborator.ProjectTable,
|
|
Columns: []string{projectcollaborator.ProjectColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(project.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.ProjectIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectcollaborator.ProjectTable,
|
|
Columns: []string{projectcollaborator.ProjectColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(project.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
_node = &ProjectCollaborator{config: _u.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{projectcollaborator.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|