618 lines
18 KiB
Go
618 lines
18 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"online-order/ent/business"
|
|
"online-order/ent/businesscategory"
|
|
"online-order/ent/predicate"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// BusinessUpdate is the builder for updating Business entities.
|
|
type BusinessUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *BusinessMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the BusinessUpdate builder.
|
|
func (bu *BusinessUpdate) Where(ps ...predicate.Business) *BusinessUpdate {
|
|
bu.mutation.Where(ps...)
|
|
return bu
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (bu *BusinessUpdate) SetName(s string) *BusinessUpdate {
|
|
bu.mutation.SetName(s)
|
|
return bu
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (bu *BusinessUpdate) SetNillableName(s *string) *BusinessUpdate {
|
|
if s != nil {
|
|
bu.SetName(*s)
|
|
}
|
|
return bu
|
|
}
|
|
|
|
// SetSlug sets the "slug" field.
|
|
func (bu *BusinessUpdate) SetSlug(s string) *BusinessUpdate {
|
|
bu.mutation.SetSlug(s)
|
|
return bu
|
|
}
|
|
|
|
// SetBotID sets the "bot_id" field.
|
|
func (bu *BusinessUpdate) SetBotID(s string) *BusinessUpdate {
|
|
bu.mutation.SetBotID(s)
|
|
return bu
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (bu *BusinessUpdate) SetDescription(s string) *BusinessUpdate {
|
|
bu.mutation.SetDescription(s)
|
|
return bu
|
|
}
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
func (bu *BusinessUpdate) SetNillableDescription(s *string) *BusinessUpdate {
|
|
if s != nil {
|
|
bu.SetDescription(*s)
|
|
}
|
|
return bu
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (bu *BusinessUpdate) ClearDescription() *BusinessUpdate {
|
|
bu.mutation.ClearDescription()
|
|
return bu
|
|
}
|
|
|
|
// SetCompany sets the "company" field.
|
|
func (bu *BusinessUpdate) SetCompany(s string) *BusinessUpdate {
|
|
bu.mutation.SetCompany(s)
|
|
return bu
|
|
}
|
|
|
|
// SetNillableCompany sets the "company" field if the given value is not nil.
|
|
func (bu *BusinessUpdate) SetNillableCompany(s *string) *BusinessUpdate {
|
|
if s != nil {
|
|
bu.SetCompany(*s)
|
|
}
|
|
return bu
|
|
}
|
|
|
|
// SetAboutUs sets the "about_us" field.
|
|
func (bu *BusinessUpdate) SetAboutUs(s string) *BusinessUpdate {
|
|
bu.mutation.SetAboutUs(s)
|
|
return bu
|
|
}
|
|
|
|
// SetNillableAboutUs sets the "about_us" field if the given value is not nil.
|
|
func (bu *BusinessUpdate) SetNillableAboutUs(s *string) *BusinessUpdate {
|
|
if s != nil {
|
|
bu.SetAboutUs(*s)
|
|
}
|
|
return bu
|
|
}
|
|
|
|
// ClearAboutUs clears the value of the "about_us" field.
|
|
func (bu *BusinessUpdate) ClearAboutUs() *BusinessUpdate {
|
|
bu.mutation.ClearAboutUs()
|
|
return bu
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (bu *BusinessUpdate) SetCreatedAt(t time.Time) *BusinessUpdate {
|
|
bu.mutation.SetCreatedAt(t)
|
|
return bu
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (bu *BusinessUpdate) SetNillableCreatedAt(t *time.Time) *BusinessUpdate {
|
|
if t != nil {
|
|
bu.SetCreatedAt(*t)
|
|
}
|
|
return bu
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (bu *BusinessUpdate) SetUpdatedAt(t time.Time) *BusinessUpdate {
|
|
bu.mutation.SetUpdatedAt(t)
|
|
return bu
|
|
}
|
|
|
|
// AddBusinessCategoryIDs adds the "businessCategory" edge to the BusinessCategory entity by IDs.
|
|
func (bu *BusinessUpdate) AddBusinessCategoryIDs(ids ...int) *BusinessUpdate {
|
|
bu.mutation.AddBusinessCategoryIDs(ids...)
|
|
return bu
|
|
}
|
|
|
|
// AddBusinessCategory adds the "businessCategory" edges to the BusinessCategory entity.
|
|
func (bu *BusinessUpdate) AddBusinessCategory(b ...*BusinessCategory) *BusinessUpdate {
|
|
ids := make([]int, len(b))
|
|
for i := range b {
|
|
ids[i] = b[i].ID
|
|
}
|
|
return bu.AddBusinessCategoryIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the BusinessMutation object of the builder.
|
|
func (bu *BusinessUpdate) Mutation() *BusinessMutation {
|
|
return bu.mutation
|
|
}
|
|
|
|
// ClearBusinessCategory clears all "businessCategory" edges to the BusinessCategory entity.
|
|
func (bu *BusinessUpdate) ClearBusinessCategory() *BusinessUpdate {
|
|
bu.mutation.ClearBusinessCategory()
|
|
return bu
|
|
}
|
|
|
|
// RemoveBusinessCategoryIDs removes the "businessCategory" edge to BusinessCategory entities by IDs.
|
|
func (bu *BusinessUpdate) RemoveBusinessCategoryIDs(ids ...int) *BusinessUpdate {
|
|
bu.mutation.RemoveBusinessCategoryIDs(ids...)
|
|
return bu
|
|
}
|
|
|
|
// RemoveBusinessCategory removes "businessCategory" edges to BusinessCategory entities.
|
|
func (bu *BusinessUpdate) RemoveBusinessCategory(b ...*BusinessCategory) *BusinessUpdate {
|
|
ids := make([]int, len(b))
|
|
for i := range b {
|
|
ids[i] = b[i].ID
|
|
}
|
|
return bu.RemoveBusinessCategoryIDs(ids...)
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (bu *BusinessUpdate) Save(ctx context.Context) (int, error) {
|
|
bu.defaults()
|
|
return withHooks(ctx, bu.sqlSave, bu.mutation, bu.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (bu *BusinessUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := bu.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (bu *BusinessUpdate) Exec(ctx context.Context) error {
|
|
_, err := bu.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (bu *BusinessUpdate) ExecX(ctx context.Context) {
|
|
if err := bu.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (bu *BusinessUpdate) defaults() {
|
|
if _, ok := bu.mutation.UpdatedAt(); !ok {
|
|
v := business.UpdateDefaultUpdatedAt()
|
|
bu.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
func (bu *BusinessUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|
_spec := sqlgraph.NewUpdateSpec(business.Table, business.Columns, sqlgraph.NewFieldSpec(business.FieldID, field.TypeInt))
|
|
if ps := bu.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := bu.mutation.Name(); ok {
|
|
_spec.SetField(business.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := bu.mutation.Slug(); ok {
|
|
_spec.SetField(business.FieldSlug, field.TypeString, value)
|
|
}
|
|
if value, ok := bu.mutation.BotID(); ok {
|
|
_spec.SetField(business.FieldBotID, field.TypeString, value)
|
|
}
|
|
if value, ok := bu.mutation.Description(); ok {
|
|
_spec.SetField(business.FieldDescription, field.TypeString, value)
|
|
}
|
|
if bu.mutation.DescriptionCleared() {
|
|
_spec.ClearField(business.FieldDescription, field.TypeString)
|
|
}
|
|
if value, ok := bu.mutation.Company(); ok {
|
|
_spec.SetField(business.FieldCompany, field.TypeString, value)
|
|
}
|
|
if value, ok := bu.mutation.AboutUs(); ok {
|
|
_spec.SetField(business.FieldAboutUs, field.TypeString, value)
|
|
}
|
|
if bu.mutation.AboutUsCleared() {
|
|
_spec.ClearField(business.FieldAboutUs, field.TypeString)
|
|
}
|
|
if value, ok := bu.mutation.CreatedAt(); ok {
|
|
_spec.SetField(business.FieldCreatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := bu.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(business.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if bu.mutation.BusinessCategoryCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: business.BusinessCategoryTable,
|
|
Columns: business.BusinessCategoryPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(businesscategory.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := bu.mutation.RemovedBusinessCategoryIDs(); len(nodes) > 0 && !bu.mutation.BusinessCategoryCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: business.BusinessCategoryTable,
|
|
Columns: business.BusinessCategoryPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(businesscategory.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 := bu.mutation.BusinessCategoryIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: business.BusinessCategoryTable,
|
|
Columns: business.BusinessCategoryPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(businesscategory.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, bu.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{business.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
bu.mutation.done = true
|
|
return n, nil
|
|
}
|
|
|
|
// BusinessUpdateOne is the builder for updating a single Business entity.
|
|
type BusinessUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *BusinessMutation
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (buo *BusinessUpdateOne) SetName(s string) *BusinessUpdateOne {
|
|
buo.mutation.SetName(s)
|
|
return buo
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (buo *BusinessUpdateOne) SetNillableName(s *string) *BusinessUpdateOne {
|
|
if s != nil {
|
|
buo.SetName(*s)
|
|
}
|
|
return buo
|
|
}
|
|
|
|
// SetSlug sets the "slug" field.
|
|
func (buo *BusinessUpdateOne) SetSlug(s string) *BusinessUpdateOne {
|
|
buo.mutation.SetSlug(s)
|
|
return buo
|
|
}
|
|
|
|
// SetBotID sets the "bot_id" field.
|
|
func (buo *BusinessUpdateOne) SetBotID(s string) *BusinessUpdateOne {
|
|
buo.mutation.SetBotID(s)
|
|
return buo
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (buo *BusinessUpdateOne) SetDescription(s string) *BusinessUpdateOne {
|
|
buo.mutation.SetDescription(s)
|
|
return buo
|
|
}
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
func (buo *BusinessUpdateOne) SetNillableDescription(s *string) *BusinessUpdateOne {
|
|
if s != nil {
|
|
buo.SetDescription(*s)
|
|
}
|
|
return buo
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (buo *BusinessUpdateOne) ClearDescription() *BusinessUpdateOne {
|
|
buo.mutation.ClearDescription()
|
|
return buo
|
|
}
|
|
|
|
// SetCompany sets the "company" field.
|
|
func (buo *BusinessUpdateOne) SetCompany(s string) *BusinessUpdateOne {
|
|
buo.mutation.SetCompany(s)
|
|
return buo
|
|
}
|
|
|
|
// SetNillableCompany sets the "company" field if the given value is not nil.
|
|
func (buo *BusinessUpdateOne) SetNillableCompany(s *string) *BusinessUpdateOne {
|
|
if s != nil {
|
|
buo.SetCompany(*s)
|
|
}
|
|
return buo
|
|
}
|
|
|
|
// SetAboutUs sets the "about_us" field.
|
|
func (buo *BusinessUpdateOne) SetAboutUs(s string) *BusinessUpdateOne {
|
|
buo.mutation.SetAboutUs(s)
|
|
return buo
|
|
}
|
|
|
|
// SetNillableAboutUs sets the "about_us" field if the given value is not nil.
|
|
func (buo *BusinessUpdateOne) SetNillableAboutUs(s *string) *BusinessUpdateOne {
|
|
if s != nil {
|
|
buo.SetAboutUs(*s)
|
|
}
|
|
return buo
|
|
}
|
|
|
|
// ClearAboutUs clears the value of the "about_us" field.
|
|
func (buo *BusinessUpdateOne) ClearAboutUs() *BusinessUpdateOne {
|
|
buo.mutation.ClearAboutUs()
|
|
return buo
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (buo *BusinessUpdateOne) SetCreatedAt(t time.Time) *BusinessUpdateOne {
|
|
buo.mutation.SetCreatedAt(t)
|
|
return buo
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (buo *BusinessUpdateOne) SetNillableCreatedAt(t *time.Time) *BusinessUpdateOne {
|
|
if t != nil {
|
|
buo.SetCreatedAt(*t)
|
|
}
|
|
return buo
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (buo *BusinessUpdateOne) SetUpdatedAt(t time.Time) *BusinessUpdateOne {
|
|
buo.mutation.SetUpdatedAt(t)
|
|
return buo
|
|
}
|
|
|
|
// AddBusinessCategoryIDs adds the "businessCategory" edge to the BusinessCategory entity by IDs.
|
|
func (buo *BusinessUpdateOne) AddBusinessCategoryIDs(ids ...int) *BusinessUpdateOne {
|
|
buo.mutation.AddBusinessCategoryIDs(ids...)
|
|
return buo
|
|
}
|
|
|
|
// AddBusinessCategory adds the "businessCategory" edges to the BusinessCategory entity.
|
|
func (buo *BusinessUpdateOne) AddBusinessCategory(b ...*BusinessCategory) *BusinessUpdateOne {
|
|
ids := make([]int, len(b))
|
|
for i := range b {
|
|
ids[i] = b[i].ID
|
|
}
|
|
return buo.AddBusinessCategoryIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the BusinessMutation object of the builder.
|
|
func (buo *BusinessUpdateOne) Mutation() *BusinessMutation {
|
|
return buo.mutation
|
|
}
|
|
|
|
// ClearBusinessCategory clears all "businessCategory" edges to the BusinessCategory entity.
|
|
func (buo *BusinessUpdateOne) ClearBusinessCategory() *BusinessUpdateOne {
|
|
buo.mutation.ClearBusinessCategory()
|
|
return buo
|
|
}
|
|
|
|
// RemoveBusinessCategoryIDs removes the "businessCategory" edge to BusinessCategory entities by IDs.
|
|
func (buo *BusinessUpdateOne) RemoveBusinessCategoryIDs(ids ...int) *BusinessUpdateOne {
|
|
buo.mutation.RemoveBusinessCategoryIDs(ids...)
|
|
return buo
|
|
}
|
|
|
|
// RemoveBusinessCategory removes "businessCategory" edges to BusinessCategory entities.
|
|
func (buo *BusinessUpdateOne) RemoveBusinessCategory(b ...*BusinessCategory) *BusinessUpdateOne {
|
|
ids := make([]int, len(b))
|
|
for i := range b {
|
|
ids[i] = b[i].ID
|
|
}
|
|
return buo.RemoveBusinessCategoryIDs(ids...)
|
|
}
|
|
|
|
// Where appends a list predicates to the BusinessUpdate builder.
|
|
func (buo *BusinessUpdateOne) Where(ps ...predicate.Business) *BusinessUpdateOne {
|
|
buo.mutation.Where(ps...)
|
|
return buo
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (buo *BusinessUpdateOne) Select(field string, fields ...string) *BusinessUpdateOne {
|
|
buo.fields = append([]string{field}, fields...)
|
|
return buo
|
|
}
|
|
|
|
// Save executes the query and returns the updated Business entity.
|
|
func (buo *BusinessUpdateOne) Save(ctx context.Context) (*Business, error) {
|
|
buo.defaults()
|
|
return withHooks(ctx, buo.sqlSave, buo.mutation, buo.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (buo *BusinessUpdateOne) SaveX(ctx context.Context) *Business {
|
|
node, err := buo.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (buo *BusinessUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := buo.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (buo *BusinessUpdateOne) ExecX(ctx context.Context) {
|
|
if err := buo.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (buo *BusinessUpdateOne) defaults() {
|
|
if _, ok := buo.mutation.UpdatedAt(); !ok {
|
|
v := business.UpdateDefaultUpdatedAt()
|
|
buo.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
func (buo *BusinessUpdateOne) sqlSave(ctx context.Context) (_node *Business, err error) {
|
|
_spec := sqlgraph.NewUpdateSpec(business.Table, business.Columns, sqlgraph.NewFieldSpec(business.FieldID, field.TypeInt))
|
|
id, ok := buo.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Business.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := buo.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, business.FieldID)
|
|
for _, f := range fields {
|
|
if !business.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != business.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := buo.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := buo.mutation.Name(); ok {
|
|
_spec.SetField(business.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := buo.mutation.Slug(); ok {
|
|
_spec.SetField(business.FieldSlug, field.TypeString, value)
|
|
}
|
|
if value, ok := buo.mutation.BotID(); ok {
|
|
_spec.SetField(business.FieldBotID, field.TypeString, value)
|
|
}
|
|
if value, ok := buo.mutation.Description(); ok {
|
|
_spec.SetField(business.FieldDescription, field.TypeString, value)
|
|
}
|
|
if buo.mutation.DescriptionCleared() {
|
|
_spec.ClearField(business.FieldDescription, field.TypeString)
|
|
}
|
|
if value, ok := buo.mutation.Company(); ok {
|
|
_spec.SetField(business.FieldCompany, field.TypeString, value)
|
|
}
|
|
if value, ok := buo.mutation.AboutUs(); ok {
|
|
_spec.SetField(business.FieldAboutUs, field.TypeString, value)
|
|
}
|
|
if buo.mutation.AboutUsCleared() {
|
|
_spec.ClearField(business.FieldAboutUs, field.TypeString)
|
|
}
|
|
if value, ok := buo.mutation.CreatedAt(); ok {
|
|
_spec.SetField(business.FieldCreatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := buo.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(business.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if buo.mutation.BusinessCategoryCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: business.BusinessCategoryTable,
|
|
Columns: business.BusinessCategoryPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(businesscategory.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := buo.mutation.RemovedBusinessCategoryIDs(); len(nodes) > 0 && !buo.mutation.BusinessCategoryCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: business.BusinessCategoryTable,
|
|
Columns: business.BusinessCategoryPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(businesscategory.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 := buo.mutation.BusinessCategoryIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: business.BusinessCategoryTable,
|
|
Columns: business.BusinessCategoryPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(businesscategory.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_node = &Business{config: buo.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, buo.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{business.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
buo.mutation.done = true
|
|
return _node, nil
|
|
}
|