1
0
api/ent/card_update.go

773 lines
20 KiB
Go
Raw Normal View History

2022-08-31 07:49:08 +00:00
// Code generated by ent, DO NOT EDIT.
package ent
import (
2024-02-21 09:16:45 +00:00
"api/ent/card"
"api/ent/predicate"
"api/ent/user"
2022-08-31 07:49:08 +00:00
"context"
"errors"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// CardUpdate is the builder for updating Card entities.
type CardUpdate struct {
config
hooks []Hook
mutation *CardMutation
}
// Where appends a list predicates to the CardUpdate builder.
func (cu *CardUpdate) Where(ps ...predicate.Card) *CardUpdate {
cu.mutation.Where(ps...)
return cu
}
2023-07-20 14:18:17 +00:00
// SetCard sets the "card" field.
func (cu *CardUpdate) SetCard(i int) *CardUpdate {
cu.mutation.ResetCard()
cu.mutation.SetCard(i)
return cu
}
// SetNillableCard sets the "card" field if the given value is not nil.
func (cu *CardUpdate) SetNillableCard(i *int) *CardUpdate {
if i != nil {
cu.SetCard(*i)
}
return cu
}
// AddCard adds i to the "card" field.
func (cu *CardUpdate) AddCard(i int) *CardUpdate {
cu.mutation.AddCard(i)
return cu
}
// ClearCard clears the value of the "card" field.
func (cu *CardUpdate) ClearCard() *CardUpdate {
cu.mutation.ClearCard()
return cu
}
2023-05-03 10:16:36 +00:00
// SetSkill sets the "skill" field.
func (cu *CardUpdate) SetSkill(s string) *CardUpdate {
cu.mutation.SetSkill(s)
return cu
}
// SetNillableSkill sets the "skill" field if the given value is not nil.
func (cu *CardUpdate) SetNillableSkill(s *string) *CardUpdate {
if s != nil {
cu.SetSkill(*s)
}
return cu
}
// ClearSkill clears the value of the "skill" field.
func (cu *CardUpdate) ClearSkill() *CardUpdate {
cu.mutation.ClearSkill()
return cu
}
2023-07-01 14:21:48 +00:00
// SetStatus sets the "status" field.
func (cu *CardUpdate) SetStatus(s string) *CardUpdate {
cu.mutation.SetStatus(s)
return cu
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (cu *CardUpdate) SetNillableStatus(s *string) *CardUpdate {
if s != nil {
cu.SetStatus(*s)
}
return cu
}
// ClearStatus clears the value of the "status" field.
func (cu *CardUpdate) ClearStatus() *CardUpdate {
cu.mutation.ClearStatus()
return cu
}
// SetToken sets the "token" field.
func (cu *CardUpdate) SetToken(s string) *CardUpdate {
cu.mutation.SetToken(s)
return cu
}
// SetNillableToken sets the "token" field if the given value is not nil.
func (cu *CardUpdate) SetNillableToken(s *string) *CardUpdate {
if s != nil {
cu.SetToken(*s)
}
return cu
}
// ClearToken clears the value of the "token" field.
func (cu *CardUpdate) ClearToken() *CardUpdate {
cu.mutation.ClearToken()
return cu
}
// SetCp sets the "cp" field.
func (cu *CardUpdate) SetCp(i int) *CardUpdate {
cu.mutation.ResetCp()
cu.mutation.SetCp(i)
return cu
}
// SetNillableCp sets the "cp" field if the given value is not nil.
func (cu *CardUpdate) SetNillableCp(i *int) *CardUpdate {
if i != nil {
cu.SetCp(*i)
}
return cu
}
// AddCp adds i to the "cp" field.
func (cu *CardUpdate) AddCp(i int) *CardUpdate {
cu.mutation.AddCp(i)
return cu
}
// ClearCp clears the value of the "cp" field.
func (cu *CardUpdate) ClearCp() *CardUpdate {
cu.mutation.ClearCp()
return cu
}
2023-08-03 03:32:44 +00:00
// SetURL sets the "url" field.
func (cu *CardUpdate) SetURL(s string) *CardUpdate {
cu.mutation.SetURL(s)
return cu
}
// SetNillableURL sets the "url" field if the given value is not nil.
func (cu *CardUpdate) SetNillableURL(s *string) *CardUpdate {
if s != nil {
cu.SetURL(*s)
}
return cu
}
// ClearURL clears the value of the "url" field.
func (cu *CardUpdate) ClearURL() *CardUpdate {
cu.mutation.ClearURL()
return cu
}
2023-08-21 13:13:44 +00:00
// SetCount sets the "count" field.
func (cu *CardUpdate) SetCount(i int) *CardUpdate {
cu.mutation.ResetCount()
cu.mutation.SetCount(i)
return cu
}
// SetNillableCount sets the "count" field if the given value is not nil.
func (cu *CardUpdate) SetNillableCount(i *int) *CardUpdate {
if i != nil {
cu.SetCount(*i)
}
return cu
}
// AddCount adds i to the "count" field.
func (cu *CardUpdate) AddCount(i int) *CardUpdate {
cu.mutation.AddCount(i)
return cu
}
// ClearCount clears the value of the "count" field.
func (cu *CardUpdate) ClearCount() *CardUpdate {
cu.mutation.ClearCount()
return cu
}
// SetAuthor sets the "author" field.
func (cu *CardUpdate) SetAuthor(s string) *CardUpdate {
cu.mutation.SetAuthor(s)
return cu
}
// SetNillableAuthor sets the "author" field if the given value is not nil.
func (cu *CardUpdate) SetNillableAuthor(s *string) *CardUpdate {
if s != nil {
cu.SetAuthor(*s)
}
return cu
}
// ClearAuthor clears the value of the "author" field.
func (cu *CardUpdate) ClearAuthor() *CardUpdate {
cu.mutation.ClearAuthor()
return cu
}
2022-08-31 07:49:08 +00:00
// SetOwnerID sets the "owner" edge to the User entity by ID.
func (cu *CardUpdate) SetOwnerID(id int) *CardUpdate {
cu.mutation.SetOwnerID(id)
return cu
}
// SetOwner sets the "owner" edge to the User entity.
func (cu *CardUpdate) SetOwner(u *User) *CardUpdate {
return cu.SetOwnerID(u.ID)
}
// Mutation returns the CardMutation object of the builder.
func (cu *CardUpdate) Mutation() *CardMutation {
return cu.mutation
}
// ClearOwner clears the "owner" edge to the User entity.
func (cu *CardUpdate) ClearOwner() *CardUpdate {
cu.mutation.ClearOwner()
return cu
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (cu *CardUpdate) Save(ctx context.Context) (int, error) {
return withHooks[int, CardMutation](ctx, cu.sqlSave, cu.mutation, cu.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (cu *CardUpdate) SaveX(ctx context.Context) int {
affected, err := cu.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (cu *CardUpdate) Exec(ctx context.Context) error {
_, err := cu.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (cu *CardUpdate) ExecX(ctx context.Context) {
if err := cu.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (cu *CardUpdate) check() error {
if _, ok := cu.mutation.OwnerID(); cu.mutation.OwnerCleared() && !ok {
return errors.New(`ent: clearing a required unique edge "Card.owner"`)
}
return nil
}
func (cu *CardUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := cu.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(card.Table, card.Columns, sqlgraph.NewFieldSpec(card.FieldID, field.TypeInt))
if ps := cu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
2023-07-20 14:18:17 +00:00
if value, ok := cu.mutation.Card(); ok {
_spec.SetField(card.FieldCard, field.TypeInt, value)
}
if value, ok := cu.mutation.AddedCard(); ok {
_spec.AddField(card.FieldCard, field.TypeInt, value)
}
2022-08-31 07:49:08 +00:00
if cu.mutation.CardCleared() {
_spec.ClearField(card.FieldCard, field.TypeInt)
}
2023-05-03 10:16:36 +00:00
if value, ok := cu.mutation.Skill(); ok {
_spec.SetField(card.FieldSkill, field.TypeString, value)
}
if cu.mutation.SkillCleared() {
_spec.ClearField(card.FieldSkill, field.TypeString)
}
2023-07-01 14:21:48 +00:00
if value, ok := cu.mutation.Status(); ok {
_spec.SetField(card.FieldStatus, field.TypeString, value)
}
2022-08-31 07:49:08 +00:00
if cu.mutation.StatusCleared() {
_spec.ClearField(card.FieldStatus, field.TypeString)
}
2023-07-01 14:21:48 +00:00
if value, ok := cu.mutation.Token(); ok {
_spec.SetField(card.FieldToken, field.TypeString, value)
}
if cu.mutation.TokenCleared() {
_spec.ClearField(card.FieldToken, field.TypeString)
}
if value, ok := cu.mutation.Cp(); ok {
_spec.SetField(card.FieldCp, field.TypeInt, value)
}
if value, ok := cu.mutation.AddedCp(); ok {
_spec.AddField(card.FieldCp, field.TypeInt, value)
}
2022-08-31 07:49:08 +00:00
if cu.mutation.CpCleared() {
_spec.ClearField(card.FieldCp, field.TypeInt)
}
2023-08-03 03:32:44 +00:00
if value, ok := cu.mutation.URL(); ok {
_spec.SetField(card.FieldURL, field.TypeString, value)
}
2022-08-31 07:49:08 +00:00
if cu.mutation.URLCleared() {
_spec.ClearField(card.FieldURL, field.TypeString)
}
2023-08-21 13:13:44 +00:00
if value, ok := cu.mutation.Count(); ok {
_spec.SetField(card.FieldCount, field.TypeInt, value)
}
if value, ok := cu.mutation.AddedCount(); ok {
_spec.AddField(card.FieldCount, field.TypeInt, value)
}
if cu.mutation.CountCleared() {
_spec.ClearField(card.FieldCount, field.TypeInt)
}
if value, ok := cu.mutation.Author(); ok {
_spec.SetField(card.FieldAuthor, field.TypeString, value)
}
if cu.mutation.AuthorCleared() {
_spec.ClearField(card.FieldAuthor, field.TypeString)
}
2022-08-31 07:49:08 +00:00
if cu.mutation.CreatedAtCleared() {
_spec.ClearField(card.FieldCreatedAt, field.TypeTime)
}
if cu.mutation.OwnerCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: card.OwnerTable,
Columns: []string{card.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2023-04-05 06:05:14 +00:00
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
2022-08-31 07:49:08 +00:00
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := cu.mutation.OwnerIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: card.OwnerTable,
Columns: []string{card.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2023-04-05 06:05:14 +00:00
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
2022-08-31 07:49:08 +00:00
},
}
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, cu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{card.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
cu.mutation.done = true
return n, nil
}
// CardUpdateOne is the builder for updating a single Card entity.
type CardUpdateOne struct {
config
fields []string
hooks []Hook
mutation *CardMutation
}
2023-07-20 14:18:17 +00:00
// SetCard sets the "card" field.
func (cuo *CardUpdateOne) SetCard(i int) *CardUpdateOne {
cuo.mutation.ResetCard()
cuo.mutation.SetCard(i)
return cuo
}
// SetNillableCard sets the "card" field if the given value is not nil.
func (cuo *CardUpdateOne) SetNillableCard(i *int) *CardUpdateOne {
if i != nil {
cuo.SetCard(*i)
}
return cuo
}
// AddCard adds i to the "card" field.
func (cuo *CardUpdateOne) AddCard(i int) *CardUpdateOne {
cuo.mutation.AddCard(i)
return cuo
}
// ClearCard clears the value of the "card" field.
func (cuo *CardUpdateOne) ClearCard() *CardUpdateOne {
cuo.mutation.ClearCard()
return cuo
}
2023-05-03 10:16:36 +00:00
// SetSkill sets the "skill" field.
func (cuo *CardUpdateOne) SetSkill(s string) *CardUpdateOne {
cuo.mutation.SetSkill(s)
return cuo
}
// SetNillableSkill sets the "skill" field if the given value is not nil.
func (cuo *CardUpdateOne) SetNillableSkill(s *string) *CardUpdateOne {
if s != nil {
cuo.SetSkill(*s)
}
return cuo
}
// ClearSkill clears the value of the "skill" field.
func (cuo *CardUpdateOne) ClearSkill() *CardUpdateOne {
cuo.mutation.ClearSkill()
return cuo
}
2023-07-01 14:21:48 +00:00
// SetStatus sets the "status" field.
func (cuo *CardUpdateOne) SetStatus(s string) *CardUpdateOne {
cuo.mutation.SetStatus(s)
return cuo
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (cuo *CardUpdateOne) SetNillableStatus(s *string) *CardUpdateOne {
if s != nil {
cuo.SetStatus(*s)
}
return cuo
}
// ClearStatus clears the value of the "status" field.
func (cuo *CardUpdateOne) ClearStatus() *CardUpdateOne {
cuo.mutation.ClearStatus()
return cuo
}
// SetToken sets the "token" field.
func (cuo *CardUpdateOne) SetToken(s string) *CardUpdateOne {
cuo.mutation.SetToken(s)
return cuo
}
// SetNillableToken sets the "token" field if the given value is not nil.
func (cuo *CardUpdateOne) SetNillableToken(s *string) *CardUpdateOne {
if s != nil {
cuo.SetToken(*s)
}
return cuo
}
// ClearToken clears the value of the "token" field.
func (cuo *CardUpdateOne) ClearToken() *CardUpdateOne {
cuo.mutation.ClearToken()
return cuo
}
// SetCp sets the "cp" field.
func (cuo *CardUpdateOne) SetCp(i int) *CardUpdateOne {
cuo.mutation.ResetCp()
cuo.mutation.SetCp(i)
return cuo
}
// SetNillableCp sets the "cp" field if the given value is not nil.
func (cuo *CardUpdateOne) SetNillableCp(i *int) *CardUpdateOne {
if i != nil {
cuo.SetCp(*i)
}
return cuo
}
// AddCp adds i to the "cp" field.
func (cuo *CardUpdateOne) AddCp(i int) *CardUpdateOne {
cuo.mutation.AddCp(i)
return cuo
}
// ClearCp clears the value of the "cp" field.
func (cuo *CardUpdateOne) ClearCp() *CardUpdateOne {
cuo.mutation.ClearCp()
return cuo
}
2023-08-03 03:32:44 +00:00
// SetURL sets the "url" field.
func (cuo *CardUpdateOne) SetURL(s string) *CardUpdateOne {
cuo.mutation.SetURL(s)
return cuo
}
// SetNillableURL sets the "url" field if the given value is not nil.
func (cuo *CardUpdateOne) SetNillableURL(s *string) *CardUpdateOne {
if s != nil {
cuo.SetURL(*s)
}
return cuo
}
// ClearURL clears the value of the "url" field.
func (cuo *CardUpdateOne) ClearURL() *CardUpdateOne {
cuo.mutation.ClearURL()
return cuo
}
2023-08-21 13:13:44 +00:00
// SetCount sets the "count" field.
func (cuo *CardUpdateOne) SetCount(i int) *CardUpdateOne {
cuo.mutation.ResetCount()
cuo.mutation.SetCount(i)
return cuo
}
// SetNillableCount sets the "count" field if the given value is not nil.
func (cuo *CardUpdateOne) SetNillableCount(i *int) *CardUpdateOne {
if i != nil {
cuo.SetCount(*i)
}
return cuo
}
// AddCount adds i to the "count" field.
func (cuo *CardUpdateOne) AddCount(i int) *CardUpdateOne {
cuo.mutation.AddCount(i)
return cuo
}
// ClearCount clears the value of the "count" field.
func (cuo *CardUpdateOne) ClearCount() *CardUpdateOne {
cuo.mutation.ClearCount()
return cuo
}
// SetAuthor sets the "author" field.
func (cuo *CardUpdateOne) SetAuthor(s string) *CardUpdateOne {
cuo.mutation.SetAuthor(s)
return cuo
}
// SetNillableAuthor sets the "author" field if the given value is not nil.
func (cuo *CardUpdateOne) SetNillableAuthor(s *string) *CardUpdateOne {
if s != nil {
cuo.SetAuthor(*s)
}
return cuo
}
// ClearAuthor clears the value of the "author" field.
func (cuo *CardUpdateOne) ClearAuthor() *CardUpdateOne {
cuo.mutation.ClearAuthor()
return cuo
}
2022-08-31 07:49:08 +00:00
// SetOwnerID sets the "owner" edge to the User entity by ID.
func (cuo *CardUpdateOne) SetOwnerID(id int) *CardUpdateOne {
cuo.mutation.SetOwnerID(id)
return cuo
}
// SetOwner sets the "owner" edge to the User entity.
func (cuo *CardUpdateOne) SetOwner(u *User) *CardUpdateOne {
return cuo.SetOwnerID(u.ID)
}
// Mutation returns the CardMutation object of the builder.
func (cuo *CardUpdateOne) Mutation() *CardMutation {
return cuo.mutation
}
// ClearOwner clears the "owner" edge to the User entity.
func (cuo *CardUpdateOne) ClearOwner() *CardUpdateOne {
cuo.mutation.ClearOwner()
return cuo
}
// Where appends a list predicates to the CardUpdate builder.
func (cuo *CardUpdateOne) Where(ps ...predicate.Card) *CardUpdateOne {
cuo.mutation.Where(ps...)
return cuo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (cuo *CardUpdateOne) Select(field string, fields ...string) *CardUpdateOne {
cuo.fields = append([]string{field}, fields...)
return cuo
}
// Save executes the query and returns the updated Card entity.
func (cuo *CardUpdateOne) Save(ctx context.Context) (*Card, error) {
return withHooks[*Card, CardMutation](ctx, cuo.sqlSave, cuo.mutation, cuo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (cuo *CardUpdateOne) SaveX(ctx context.Context) *Card {
node, err := cuo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (cuo *CardUpdateOne) Exec(ctx context.Context) error {
_, err := cuo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (cuo *CardUpdateOne) ExecX(ctx context.Context) {
if err := cuo.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (cuo *CardUpdateOne) check() error {
if _, ok := cuo.mutation.OwnerID(); cuo.mutation.OwnerCleared() && !ok {
return errors.New(`ent: clearing a required unique edge "Card.owner"`)
}
return nil
}
func (cuo *CardUpdateOne) sqlSave(ctx context.Context) (_node *Card, err error) {
if err := cuo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(card.Table, card.Columns, sqlgraph.NewFieldSpec(card.FieldID, field.TypeInt))
id, ok := cuo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Card.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := cuo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, card.FieldID)
for _, f := range fields {
if !card.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != card.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := cuo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
2023-07-20 14:18:17 +00:00
if value, ok := cuo.mutation.Card(); ok {
_spec.SetField(card.FieldCard, field.TypeInt, value)
}
if value, ok := cuo.mutation.AddedCard(); ok {
_spec.AddField(card.FieldCard, field.TypeInt, value)
}
2022-08-31 07:49:08 +00:00
if cuo.mutation.CardCleared() {
_spec.ClearField(card.FieldCard, field.TypeInt)
}
2023-05-03 10:16:36 +00:00
if value, ok := cuo.mutation.Skill(); ok {
_spec.SetField(card.FieldSkill, field.TypeString, value)
}
if cuo.mutation.SkillCleared() {
_spec.ClearField(card.FieldSkill, field.TypeString)
}
2023-07-01 14:21:48 +00:00
if value, ok := cuo.mutation.Status(); ok {
_spec.SetField(card.FieldStatus, field.TypeString, value)
}
2022-08-31 07:49:08 +00:00
if cuo.mutation.StatusCleared() {
_spec.ClearField(card.FieldStatus, field.TypeString)
}
2023-07-01 14:21:48 +00:00
if value, ok := cuo.mutation.Token(); ok {
_spec.SetField(card.FieldToken, field.TypeString, value)
}
if cuo.mutation.TokenCleared() {
_spec.ClearField(card.FieldToken, field.TypeString)
}
if value, ok := cuo.mutation.Cp(); ok {
_spec.SetField(card.FieldCp, field.TypeInt, value)
}
if value, ok := cuo.mutation.AddedCp(); ok {
_spec.AddField(card.FieldCp, field.TypeInt, value)
}
2022-08-31 07:49:08 +00:00
if cuo.mutation.CpCleared() {
_spec.ClearField(card.FieldCp, field.TypeInt)
}
2023-08-03 03:32:44 +00:00
if value, ok := cuo.mutation.URL(); ok {
_spec.SetField(card.FieldURL, field.TypeString, value)
}
2022-08-31 07:49:08 +00:00
if cuo.mutation.URLCleared() {
_spec.ClearField(card.FieldURL, field.TypeString)
}
2023-08-21 13:13:44 +00:00
if value, ok := cuo.mutation.Count(); ok {
_spec.SetField(card.FieldCount, field.TypeInt, value)
}
if value, ok := cuo.mutation.AddedCount(); ok {
_spec.AddField(card.FieldCount, field.TypeInt, value)
}
if cuo.mutation.CountCleared() {
_spec.ClearField(card.FieldCount, field.TypeInt)
}
if value, ok := cuo.mutation.Author(); ok {
_spec.SetField(card.FieldAuthor, field.TypeString, value)
}
if cuo.mutation.AuthorCleared() {
_spec.ClearField(card.FieldAuthor, field.TypeString)
}
2022-08-31 07:49:08 +00:00
if cuo.mutation.CreatedAtCleared() {
_spec.ClearField(card.FieldCreatedAt, field.TypeTime)
}
if cuo.mutation.OwnerCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: card.OwnerTable,
Columns: []string{card.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2023-04-05 06:05:14 +00:00
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
2022-08-31 07:49:08 +00:00
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := cuo.mutation.OwnerIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: card.OwnerTable,
Columns: []string{card.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
2023-04-05 06:05:14 +00:00
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
2022-08-31 07:49:08 +00:00
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_node = &Card{config: cuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{card.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
cuo.mutation.done = true
return _node, nil
}