// Code generated by ent, DO NOT EDIT. package db import ( "context" "errors" "fmt" "time" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/chaitin/MonkeyCode/backend/db/audit" "github.com/chaitin/MonkeyCode/backend/db/user" "github.com/google/uuid" ) // AuditCreate is the builder for creating a Audit entity. type AuditCreate struct { config mutation *AuditMutation hooks []Hook conflict []sql.ConflictOption } // SetUserID sets the "user_id" field. func (_c *AuditCreate) SetUserID(v uuid.UUID) *AuditCreate { _c.mutation.SetUserID(v) return _c } // SetOperation sets the "operation" field. func (_c *AuditCreate) SetOperation(v string) *AuditCreate { _c.mutation.SetOperation(v) return _c } // SetSourceIP sets the "source_ip" field. func (_c *AuditCreate) SetSourceIP(v string) *AuditCreate { _c.mutation.SetSourceIP(v) return _c } // SetUserAgent sets the "user_agent" field. func (_c *AuditCreate) SetUserAgent(v string) *AuditCreate { _c.mutation.SetUserAgent(v) return _c } // SetRequest sets the "request" field. func (_c *AuditCreate) SetRequest(v string) *AuditCreate { _c.mutation.SetRequest(v) return _c } // SetResponse sets the "response" field. func (_c *AuditCreate) SetResponse(v string) *AuditCreate { _c.mutation.SetResponse(v) return _c } // SetNillableResponse sets the "response" field if the given value is not nil. func (_c *AuditCreate) SetNillableResponse(v *string) *AuditCreate { if v != nil { _c.SetResponse(*v) } return _c } // SetCreatedAt sets the "created_at" field. func (_c *AuditCreate) SetCreatedAt(v time.Time) *AuditCreate { _c.mutation.SetCreatedAt(v) return _c } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. func (_c *AuditCreate) SetNillableCreatedAt(v *time.Time) *AuditCreate { if v != nil { _c.SetCreatedAt(*v) } return _c } // SetID sets the "id" field. func (_c *AuditCreate) SetID(v uuid.UUID) *AuditCreate { _c.mutation.SetID(v) return _c } // SetUser sets the "user" edge to the User entity. func (_c *AuditCreate) SetUser(v *User) *AuditCreate { return _c.SetUserID(v.ID) } // Mutation returns the AuditMutation object of the builder. func (_c *AuditCreate) Mutation() *AuditMutation { return _c.mutation } // Save creates the Audit in the database. func (_c *AuditCreate) Save(ctx context.Context) (*Audit, error) { _c.defaults() return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. func (_c *AuditCreate) SaveX(ctx context.Context) *Audit { v, err := _c.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (_c *AuditCreate) Exec(ctx context.Context) error { _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_c *AuditCreate) ExecX(ctx context.Context) { if err := _c.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. func (_c *AuditCreate) defaults() { if _, ok := _c.mutation.CreatedAt(); !ok { v := audit.DefaultCreatedAt() _c.mutation.SetCreatedAt(v) } } // check runs all checks and user-defined validators on the builder. func (_c *AuditCreate) check() error { if _, ok := _c.mutation.UserID(); !ok { return &ValidationError{Name: "user_id", err: errors.New(`db: missing required field "Audit.user_id"`)} } if _, ok := _c.mutation.Operation(); !ok { return &ValidationError{Name: "operation", err: errors.New(`db: missing required field "Audit.operation"`)} } if _, ok := _c.mutation.SourceIP(); !ok { return &ValidationError{Name: "source_ip", err: errors.New(`db: missing required field "Audit.source_ip"`)} } if _, ok := _c.mutation.UserAgent(); !ok { return &ValidationError{Name: "user_agent", err: errors.New(`db: missing required field "Audit.user_agent"`)} } if _, ok := _c.mutation.Request(); !ok { return &ValidationError{Name: "request", err: errors.New(`db: missing required field "Audit.request"`)} } if _, ok := _c.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "Audit.created_at"`)} } if len(_c.mutation.UserIDs()) == 0 { return &ValidationError{Name: "user", err: errors.New(`db: missing required edge "Audit.user"`)} } return nil } func (_c *AuditCreate) sqlSave(ctx context.Context) (*Audit, error) { if err := _c.check(); err != nil { return nil, err } _node, _spec := _c.createSpec() if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return nil, err } if _spec.ID.Value != nil { if id, ok := _spec.ID.Value.(*uuid.UUID); ok { _node.ID = *id } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { return nil, err } } _c.mutation.id = &_node.ID _c.mutation.done = true return _node, nil } func (_c *AuditCreate) createSpec() (*Audit, *sqlgraph.CreateSpec) { var ( _node = &Audit{config: _c.config} _spec = sqlgraph.NewCreateSpec(audit.Table, sqlgraph.NewFieldSpec(audit.FieldID, field.TypeUUID)) ) _spec.OnConflict = _c.conflict if id, ok := _c.mutation.ID(); ok { _node.ID = id _spec.ID.Value = &id } if value, ok := _c.mutation.Operation(); ok { _spec.SetField(audit.FieldOperation, field.TypeString, value) _node.Operation = value } if value, ok := _c.mutation.SourceIP(); ok { _spec.SetField(audit.FieldSourceIP, field.TypeString, value) _node.SourceIP = value } if value, ok := _c.mutation.UserAgent(); ok { _spec.SetField(audit.FieldUserAgent, field.TypeString, value) _node.UserAgent = value } if value, ok := _c.mutation.Request(); ok { _spec.SetField(audit.FieldRequest, field.TypeString, value) _node.Request = value } if value, ok := _c.mutation.Response(); ok { _spec.SetField(audit.FieldResponse, field.TypeString, value) _node.Response = value } if value, ok := _c.mutation.CreatedAt(); ok { _spec.SetField(audit.FieldCreatedAt, field.TypeTime, value) _node.CreatedAt = value } if nodes := _c.mutation.UserIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: audit.UserTable, Columns: []string{audit.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) } _node.UserID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } return _node, _spec } // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // of the `INSERT` statement. For example: // // client.Audit.Create(). // SetUserID(v). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. // sql.ResolveWithNewValues(), // ). // // Override some of the fields with custom // // update values. // Update(func(u *ent.AuditUpsert) { // SetUserID(v+v). // }). // Exec(ctx) func (_c *AuditCreate) OnConflict(opts ...sql.ConflictOption) *AuditUpsertOne { _c.conflict = opts return &AuditUpsertOne{ create: _c, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.Audit.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (_c *AuditCreate) OnConflictColumns(columns ...string) *AuditUpsertOne { _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) return &AuditUpsertOne{ create: _c, } } type ( // AuditUpsertOne is the builder for "upsert"-ing // one Audit node. AuditUpsertOne struct { create *AuditCreate } // AuditUpsert is the "OnConflict" setter. AuditUpsert struct { *sql.UpdateSet } ) // SetUserID sets the "user_id" field. func (u *AuditUpsert) SetUserID(v uuid.UUID) *AuditUpsert { u.Set(audit.FieldUserID, v) return u } // UpdateUserID sets the "user_id" field to the value that was provided on create. func (u *AuditUpsert) UpdateUserID() *AuditUpsert { u.SetExcluded(audit.FieldUserID) return u } // SetOperation sets the "operation" field. func (u *AuditUpsert) SetOperation(v string) *AuditUpsert { u.Set(audit.FieldOperation, v) return u } // UpdateOperation sets the "operation" field to the value that was provided on create. func (u *AuditUpsert) UpdateOperation() *AuditUpsert { u.SetExcluded(audit.FieldOperation) return u } // SetSourceIP sets the "source_ip" field. func (u *AuditUpsert) SetSourceIP(v string) *AuditUpsert { u.Set(audit.FieldSourceIP, v) return u } // UpdateSourceIP sets the "source_ip" field to the value that was provided on create. func (u *AuditUpsert) UpdateSourceIP() *AuditUpsert { u.SetExcluded(audit.FieldSourceIP) return u } // SetUserAgent sets the "user_agent" field. func (u *AuditUpsert) SetUserAgent(v string) *AuditUpsert { u.Set(audit.FieldUserAgent, v) return u } // UpdateUserAgent sets the "user_agent" field to the value that was provided on create. func (u *AuditUpsert) UpdateUserAgent() *AuditUpsert { u.SetExcluded(audit.FieldUserAgent) return u } // SetRequest sets the "request" field. func (u *AuditUpsert) SetRequest(v string) *AuditUpsert { u.Set(audit.FieldRequest, v) return u } // UpdateRequest sets the "request" field to the value that was provided on create. func (u *AuditUpsert) UpdateRequest() *AuditUpsert { u.SetExcluded(audit.FieldRequest) return u } // SetResponse sets the "response" field. func (u *AuditUpsert) SetResponse(v string) *AuditUpsert { u.Set(audit.FieldResponse, v) return u } // UpdateResponse sets the "response" field to the value that was provided on create. func (u *AuditUpsert) UpdateResponse() *AuditUpsert { u.SetExcluded(audit.FieldResponse) return u } // ClearResponse clears the value of the "response" field. func (u *AuditUpsert) ClearResponse() *AuditUpsert { u.SetNull(audit.FieldResponse) return u } // SetCreatedAt sets the "created_at" field. func (u *AuditUpsert) SetCreatedAt(v time.Time) *AuditUpsert { u.Set(audit.FieldCreatedAt, v) return u } // UpdateCreatedAt sets the "created_at" field to the value that was provided on create. func (u *AuditUpsert) UpdateCreatedAt() *AuditUpsert { u.SetExcluded(audit.FieldCreatedAt) return u } // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. // Using this option is equivalent to using: // // client.Audit.Create(). // OnConflict( // sql.ResolveWithNewValues(), // sql.ResolveWith(func(u *sql.UpdateSet) { // u.SetIgnore(audit.FieldID) // }), // ). // Exec(ctx) func (u *AuditUpsertOne) UpdateNewValues() *AuditUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { if _, exists := u.create.mutation.ID(); exists { s.SetIgnore(audit.FieldID) } })) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.Audit.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *AuditUpsertOne) Ignore() *AuditUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) return u } // DoNothing configures the conflict_action to `DO NOTHING`. // Supported only by SQLite and PostgreSQL. func (u *AuditUpsertOne) DoNothing() *AuditUpsertOne { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the AuditCreate.OnConflict // documentation for more info. func (u *AuditUpsertOne) Update(set func(*AuditUpsert)) *AuditUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&AuditUpsert{UpdateSet: update}) })) return u } // SetUserID sets the "user_id" field. func (u *AuditUpsertOne) SetUserID(v uuid.UUID) *AuditUpsertOne { return u.Update(func(s *AuditUpsert) { s.SetUserID(v) }) } // UpdateUserID sets the "user_id" field to the value that was provided on create. func (u *AuditUpsertOne) UpdateUserID() *AuditUpsertOne { return u.Update(func(s *AuditUpsert) { s.UpdateUserID() }) } // SetOperation sets the "operation" field. func (u *AuditUpsertOne) SetOperation(v string) *AuditUpsertOne { return u.Update(func(s *AuditUpsert) { s.SetOperation(v) }) } // UpdateOperation sets the "operation" field to the value that was provided on create. func (u *AuditUpsertOne) UpdateOperation() *AuditUpsertOne { return u.Update(func(s *AuditUpsert) { s.UpdateOperation() }) } // SetSourceIP sets the "source_ip" field. func (u *AuditUpsertOne) SetSourceIP(v string) *AuditUpsertOne { return u.Update(func(s *AuditUpsert) { s.SetSourceIP(v) }) } // UpdateSourceIP sets the "source_ip" field to the value that was provided on create. func (u *AuditUpsertOne) UpdateSourceIP() *AuditUpsertOne { return u.Update(func(s *AuditUpsert) { s.UpdateSourceIP() }) } // SetUserAgent sets the "user_agent" field. func (u *AuditUpsertOne) SetUserAgent(v string) *AuditUpsertOne { return u.Update(func(s *AuditUpsert) { s.SetUserAgent(v) }) } // UpdateUserAgent sets the "user_agent" field to the value that was provided on create. func (u *AuditUpsertOne) UpdateUserAgent() *AuditUpsertOne { return u.Update(func(s *AuditUpsert) { s.UpdateUserAgent() }) } // SetRequest sets the "request" field. func (u *AuditUpsertOne) SetRequest(v string) *AuditUpsertOne { return u.Update(func(s *AuditUpsert) { s.SetRequest(v) }) } // UpdateRequest sets the "request" field to the value that was provided on create. func (u *AuditUpsertOne) UpdateRequest() *AuditUpsertOne { return u.Update(func(s *AuditUpsert) { s.UpdateRequest() }) } // SetResponse sets the "response" field. func (u *AuditUpsertOne) SetResponse(v string) *AuditUpsertOne { return u.Update(func(s *AuditUpsert) { s.SetResponse(v) }) } // UpdateResponse sets the "response" field to the value that was provided on create. func (u *AuditUpsertOne) UpdateResponse() *AuditUpsertOne { return u.Update(func(s *AuditUpsert) { s.UpdateResponse() }) } // ClearResponse clears the value of the "response" field. func (u *AuditUpsertOne) ClearResponse() *AuditUpsertOne { return u.Update(func(s *AuditUpsert) { s.ClearResponse() }) } // SetCreatedAt sets the "created_at" field. func (u *AuditUpsertOne) SetCreatedAt(v time.Time) *AuditUpsertOne { return u.Update(func(s *AuditUpsert) { s.SetCreatedAt(v) }) } // UpdateCreatedAt sets the "created_at" field to the value that was provided on create. func (u *AuditUpsertOne) UpdateCreatedAt() *AuditUpsertOne { return u.Update(func(s *AuditUpsert) { s.UpdateCreatedAt() }) } // Exec executes the query. func (u *AuditUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { return errors.New("db: missing options for AuditCreate.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *AuditUpsertOne) ExecX(ctx context.Context) { if err := u.create.Exec(ctx); err != nil { panic(err) } } // Exec executes the UPSERT query and returns the inserted/updated ID. func (u *AuditUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) { if u.create.driver.Dialect() == dialect.MySQL { // In case of "ON CONFLICT", there is no way to get back non-numeric ID // fields from the database since MySQL does not support the RETURNING clause. return id, errors.New("db: AuditUpsertOne.ID is not supported by MySQL driver. Use AuditUpsertOne.Exec instead") } node, err := u.create.Save(ctx) if err != nil { return id, err } return node.ID, nil } // IDX is like ID, but panics if an error occurs. func (u *AuditUpsertOne) IDX(ctx context.Context) uuid.UUID { id, err := u.ID(ctx) if err != nil { panic(err) } return id } // AuditCreateBulk is the builder for creating many Audit entities in bulk. type AuditCreateBulk struct { config err error builders []*AuditCreate conflict []sql.ConflictOption } // Save creates the Audit entities in the database. func (_c *AuditCreateBulk) Save(ctx context.Context) ([]*Audit, error) { if _c.err != nil { return nil, _c.err } specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) nodes := make([]*Audit, len(_c.builders)) mutators := make([]Mutator, len(_c.builders)) for i := range _c.builders { func(i int, root context.Context) { builder := _c.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*AuditMutation) if !ok { return nil, fmt.Errorf("unexpected mutation type %T", m) } if err := builder.check(); err != nil { return nil, err } builder.mutation = mutation var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} spec.OnConflict = _c.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } } } if err != nil { return nil, err } mutation.id = &nodes[i].ID mutation.done = true return nodes[i], nil }) for i := len(builder.hooks) - 1; i >= 0; i-- { mut = builder.hooks[i](mut) } mutators[i] = mut }(i, ctx) } if len(mutators) > 0 { if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } return nodes, nil } // SaveX is like Save, but panics if an error occurs. func (_c *AuditCreateBulk) SaveX(ctx context.Context) []*Audit { v, err := _c.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (_c *AuditCreateBulk) Exec(ctx context.Context) error { _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_c *AuditCreateBulk) ExecX(ctx context.Context) { if err := _c.Exec(ctx); err != nil { panic(err) } } // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // of the `INSERT` statement. For example: // // client.Audit.CreateBulk(builders...). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. // sql.ResolveWithNewValues(), // ). // // Override some of the fields with custom // // update values. // Update(func(u *ent.AuditUpsert) { // SetUserID(v+v). // }). // Exec(ctx) func (_c *AuditCreateBulk) OnConflict(opts ...sql.ConflictOption) *AuditUpsertBulk { _c.conflict = opts return &AuditUpsertBulk{ create: _c, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.Audit.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (_c *AuditCreateBulk) OnConflictColumns(columns ...string) *AuditUpsertBulk { _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) return &AuditUpsertBulk{ create: _c, } } // AuditUpsertBulk is the builder for "upsert"-ing // a bulk of Audit nodes. type AuditUpsertBulk struct { create *AuditCreateBulk } // UpdateNewValues updates the mutable fields using the new values that // were set on create. Using this option is equivalent to using: // // client.Audit.Create(). // OnConflict( // sql.ResolveWithNewValues(), // sql.ResolveWith(func(u *sql.UpdateSet) { // u.SetIgnore(audit.FieldID) // }), // ). // Exec(ctx) func (u *AuditUpsertBulk) UpdateNewValues() *AuditUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { for _, b := range u.create.builders { if _, exists := b.mutation.ID(); exists { s.SetIgnore(audit.FieldID) } } })) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.Audit.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *AuditUpsertBulk) Ignore() *AuditUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) return u } // DoNothing configures the conflict_action to `DO NOTHING`. // Supported only by SQLite and PostgreSQL. func (u *AuditUpsertBulk) DoNothing() *AuditUpsertBulk { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the AuditCreateBulk.OnConflict // documentation for more info. func (u *AuditUpsertBulk) Update(set func(*AuditUpsert)) *AuditUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&AuditUpsert{UpdateSet: update}) })) return u } // SetUserID sets the "user_id" field. func (u *AuditUpsertBulk) SetUserID(v uuid.UUID) *AuditUpsertBulk { return u.Update(func(s *AuditUpsert) { s.SetUserID(v) }) } // UpdateUserID sets the "user_id" field to the value that was provided on create. func (u *AuditUpsertBulk) UpdateUserID() *AuditUpsertBulk { return u.Update(func(s *AuditUpsert) { s.UpdateUserID() }) } // SetOperation sets the "operation" field. func (u *AuditUpsertBulk) SetOperation(v string) *AuditUpsertBulk { return u.Update(func(s *AuditUpsert) { s.SetOperation(v) }) } // UpdateOperation sets the "operation" field to the value that was provided on create. func (u *AuditUpsertBulk) UpdateOperation() *AuditUpsertBulk { return u.Update(func(s *AuditUpsert) { s.UpdateOperation() }) } // SetSourceIP sets the "source_ip" field. func (u *AuditUpsertBulk) SetSourceIP(v string) *AuditUpsertBulk { return u.Update(func(s *AuditUpsert) { s.SetSourceIP(v) }) } // UpdateSourceIP sets the "source_ip" field to the value that was provided on create. func (u *AuditUpsertBulk) UpdateSourceIP() *AuditUpsertBulk { return u.Update(func(s *AuditUpsert) { s.UpdateSourceIP() }) } // SetUserAgent sets the "user_agent" field. func (u *AuditUpsertBulk) SetUserAgent(v string) *AuditUpsertBulk { return u.Update(func(s *AuditUpsert) { s.SetUserAgent(v) }) } // UpdateUserAgent sets the "user_agent" field to the value that was provided on create. func (u *AuditUpsertBulk) UpdateUserAgent() *AuditUpsertBulk { return u.Update(func(s *AuditUpsert) { s.UpdateUserAgent() }) } // SetRequest sets the "request" field. func (u *AuditUpsertBulk) SetRequest(v string) *AuditUpsertBulk { return u.Update(func(s *AuditUpsert) { s.SetRequest(v) }) } // UpdateRequest sets the "request" field to the value that was provided on create. func (u *AuditUpsertBulk) UpdateRequest() *AuditUpsertBulk { return u.Update(func(s *AuditUpsert) { s.UpdateRequest() }) } // SetResponse sets the "response" field. func (u *AuditUpsertBulk) SetResponse(v string) *AuditUpsertBulk { return u.Update(func(s *AuditUpsert) { s.SetResponse(v) }) } // UpdateResponse sets the "response" field to the value that was provided on create. func (u *AuditUpsertBulk) UpdateResponse() *AuditUpsertBulk { return u.Update(func(s *AuditUpsert) { s.UpdateResponse() }) } // ClearResponse clears the value of the "response" field. func (u *AuditUpsertBulk) ClearResponse() *AuditUpsertBulk { return u.Update(func(s *AuditUpsert) { s.ClearResponse() }) } // SetCreatedAt sets the "created_at" field. func (u *AuditUpsertBulk) SetCreatedAt(v time.Time) *AuditUpsertBulk { return u.Update(func(s *AuditUpsert) { s.SetCreatedAt(v) }) } // UpdateCreatedAt sets the "created_at" field to the value that was provided on create. func (u *AuditUpsertBulk) UpdateCreatedAt() *AuditUpsertBulk { return u.Update(func(s *AuditUpsert) { s.UpdateCreatedAt() }) } // Exec executes the query. func (u *AuditUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { return u.create.err } for i, b := range u.create.builders { if len(b.conflict) != 0 { return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the AuditCreateBulk instead", i) } } if len(u.create.conflict) == 0 { return errors.New("db: missing options for AuditCreateBulk.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *AuditUpsertBulk) ExecX(ctx context.Context) { if err := u.create.Exec(ctx); err != nil { panic(err) } }