12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "wechat-api/ent/agent"
- "wechat-api/ent/apikey"
- "wechat-api/ent/token"
- "wechat-api/ent/whatsapp"
- "wechat-api/ent/wx"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- )
- // AgentCreate is the builder for creating a Agent entity.
- type AgentCreate struct {
- config
- mutation *AgentMutation
- hooks []Hook
- conflict []sql.ConflictOption
- }
- // SetCreatedAt sets the "created_at" field.
- func (ac *AgentCreate) SetCreatedAt(t time.Time) *AgentCreate {
- ac.mutation.SetCreatedAt(t)
- return ac
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (ac *AgentCreate) SetNillableCreatedAt(t *time.Time) *AgentCreate {
- if t != nil {
- ac.SetCreatedAt(*t)
- }
- return ac
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (ac *AgentCreate) SetUpdatedAt(t time.Time) *AgentCreate {
- ac.mutation.SetUpdatedAt(t)
- return ac
- }
- // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
- func (ac *AgentCreate) SetNillableUpdatedAt(t *time.Time) *AgentCreate {
- if t != nil {
- ac.SetUpdatedAt(*t)
- }
- return ac
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (ac *AgentCreate) SetDeletedAt(t time.Time) *AgentCreate {
- ac.mutation.SetDeletedAt(t)
- return ac
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (ac *AgentCreate) SetNillableDeletedAt(t *time.Time) *AgentCreate {
- if t != nil {
- ac.SetDeletedAt(*t)
- }
- return ac
- }
- // SetName sets the "name" field.
- func (ac *AgentCreate) SetName(s string) *AgentCreate {
- ac.mutation.SetName(s)
- return ac
- }
- // SetRole sets the "role" field.
- func (ac *AgentCreate) SetRole(s string) *AgentCreate {
- ac.mutation.SetRole(s)
- return ac
- }
- // SetStatus sets the "status" field.
- func (ac *AgentCreate) SetStatus(i int) *AgentCreate {
- ac.mutation.SetStatus(i)
- return ac
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (ac *AgentCreate) SetNillableStatus(i *int) *AgentCreate {
- if i != nil {
- ac.SetStatus(*i)
- }
- return ac
- }
- // SetBackground sets the "background" field.
- func (ac *AgentCreate) SetBackground(s string) *AgentCreate {
- ac.mutation.SetBackground(s)
- return ac
- }
- // SetNillableBackground sets the "background" field if the given value is not nil.
- func (ac *AgentCreate) SetNillableBackground(s *string) *AgentCreate {
- if s != nil {
- ac.SetBackground(*s)
- }
- return ac
- }
- // SetExamples sets the "examples" field.
- func (ac *AgentCreate) SetExamples(s string) *AgentCreate {
- ac.mutation.SetExamples(s)
- return ac
- }
- // SetNillableExamples sets the "examples" field if the given value is not nil.
- func (ac *AgentCreate) SetNillableExamples(s *string) *AgentCreate {
- if s != nil {
- ac.SetExamples(*s)
- }
- return ac
- }
- // SetOrganizationID sets the "organization_id" field.
- func (ac *AgentCreate) SetOrganizationID(u uint64) *AgentCreate {
- ac.mutation.SetOrganizationID(u)
- return ac
- }
- // SetDatasetID sets the "dataset_id" field.
- func (ac *AgentCreate) SetDatasetID(s string) *AgentCreate {
- ac.mutation.SetDatasetID(s)
- return ac
- }
- // SetNillableDatasetID sets the "dataset_id" field if the given value is not nil.
- func (ac *AgentCreate) SetNillableDatasetID(s *string) *AgentCreate {
- if s != nil {
- ac.SetDatasetID(*s)
- }
- return ac
- }
- // SetCollectionID sets the "collection_id" field.
- func (ac *AgentCreate) SetCollectionID(s string) *AgentCreate {
- ac.mutation.SetCollectionID(s)
- return ac
- }
- // SetNillableCollectionID sets the "collection_id" field if the given value is not nil.
- func (ac *AgentCreate) SetNillableCollectionID(s *string) *AgentCreate {
- if s != nil {
- ac.SetCollectionID(*s)
- }
- return ac
- }
- // SetID sets the "id" field.
- func (ac *AgentCreate) SetID(u uint64) *AgentCreate {
- ac.mutation.SetID(u)
- return ac
- }
- // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by IDs.
- func (ac *AgentCreate) AddWxAgentIDs(ids ...uint64) *AgentCreate {
- ac.mutation.AddWxAgentIDs(ids...)
- return ac
- }
- // AddWxAgent adds the "wx_agent" edges to the Wx entity.
- func (ac *AgentCreate) AddWxAgent(w ...*Wx) *AgentCreate {
- ids := make([]uint64, len(w))
- for i := range w {
- ids[i] = w[i].ID
- }
- return ac.AddWxAgentIDs(ids...)
- }
- // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by IDs.
- func (ac *AgentCreate) AddTokenAgentIDs(ids ...uint64) *AgentCreate {
- ac.mutation.AddTokenAgentIDs(ids...)
- return ac
- }
- // AddTokenAgent adds the "token_agent" edges to the Token entity.
- func (ac *AgentCreate) AddTokenAgent(t ...*Token) *AgentCreate {
- ids := make([]uint64, len(t))
- for i := range t {
- ids[i] = t[i].ID
- }
- return ac.AddTokenAgentIDs(ids...)
- }
- // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by IDs.
- func (ac *AgentCreate) AddWaAgentIDs(ids ...uint64) *AgentCreate {
- ac.mutation.AddWaAgentIDs(ids...)
- return ac
- }
- // AddWaAgent adds the "wa_agent" edges to the Whatsapp entity.
- func (ac *AgentCreate) AddWaAgent(w ...*Whatsapp) *AgentCreate {
- ids := make([]uint64, len(w))
- for i := range w {
- ids[i] = w[i].ID
- }
- return ac.AddWaAgentIDs(ids...)
- }
- // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by IDs.
- func (ac *AgentCreate) AddKeyAgentIDs(ids ...uint64) *AgentCreate {
- ac.mutation.AddKeyAgentIDs(ids...)
- return ac
- }
- // AddKeyAgent adds the "key_agent" edges to the ApiKey entity.
- func (ac *AgentCreate) AddKeyAgent(a ...*ApiKey) *AgentCreate {
- ids := make([]uint64, len(a))
- for i := range a {
- ids[i] = a[i].ID
- }
- return ac.AddKeyAgentIDs(ids...)
- }
- // Mutation returns the AgentMutation object of the builder.
- func (ac *AgentCreate) Mutation() *AgentMutation {
- return ac.mutation
- }
- // Save creates the Agent in the database.
- func (ac *AgentCreate) Save(ctx context.Context) (*Agent, error) {
- if err := ac.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, ac.sqlSave, ac.mutation, ac.hooks)
- }
- // SaveX calls Save and panics if Save returns an error.
- func (ac *AgentCreate) SaveX(ctx context.Context) *Agent {
- v, err := ac.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (ac *AgentCreate) Exec(ctx context.Context) error {
- _, err := ac.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (ac *AgentCreate) ExecX(ctx context.Context) {
- if err := ac.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (ac *AgentCreate) defaults() error {
- if _, ok := ac.mutation.CreatedAt(); !ok {
- if agent.DefaultCreatedAt == nil {
- return fmt.Errorf("ent: uninitialized agent.DefaultCreatedAt (forgotten import ent/runtime?)")
- }
- v := agent.DefaultCreatedAt()
- ac.mutation.SetCreatedAt(v)
- }
- if _, ok := ac.mutation.UpdatedAt(); !ok {
- if agent.DefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized agent.DefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := agent.DefaultUpdatedAt()
- ac.mutation.SetUpdatedAt(v)
- }
- if _, ok := ac.mutation.Status(); !ok {
- v := agent.DefaultStatus
- ac.mutation.SetStatus(v)
- }
- if _, ok := ac.mutation.Background(); !ok {
- v := agent.DefaultBackground
- ac.mutation.SetBackground(v)
- }
- if _, ok := ac.mutation.Examples(); !ok {
- v := agent.DefaultExamples
- ac.mutation.SetExamples(v)
- }
- if _, ok := ac.mutation.DatasetID(); !ok {
- v := agent.DefaultDatasetID
- ac.mutation.SetDatasetID(v)
- }
- if _, ok := ac.mutation.CollectionID(); !ok {
- v := agent.DefaultCollectionID
- ac.mutation.SetCollectionID(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (ac *AgentCreate) check() error {
- if _, ok := ac.mutation.CreatedAt(); !ok {
- return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Agent.created_at"`)}
- }
- if _, ok := ac.mutation.UpdatedAt(); !ok {
- return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Agent.updated_at"`)}
- }
- if _, ok := ac.mutation.Name(); !ok {
- return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Agent.name"`)}
- }
- if v, ok := ac.mutation.Name(); ok {
- if err := agent.NameValidator(v); err != nil {
- return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Agent.name": %w`, err)}
- }
- }
- if _, ok := ac.mutation.Role(); !ok {
- return &ValidationError{Name: "role", err: errors.New(`ent: missing required field "Agent.role"`)}
- }
- if v, ok := ac.mutation.Status(); ok {
- if err := agent.StatusValidator(v); err != nil {
- return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Agent.status": %w`, err)}
- }
- }
- if _, ok := ac.mutation.OrganizationID(); !ok {
- return &ValidationError{Name: "organization_id", err: errors.New(`ent: missing required field "Agent.organization_id"`)}
- }
- if v, ok := ac.mutation.OrganizationID(); ok {
- if err := agent.OrganizationIDValidator(v); err != nil {
- return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "Agent.organization_id": %w`, err)}
- }
- }
- if _, ok := ac.mutation.DatasetID(); !ok {
- return &ValidationError{Name: "dataset_id", err: errors.New(`ent: missing required field "Agent.dataset_id"`)}
- }
- if v, ok := ac.mutation.DatasetID(); ok {
- if err := agent.DatasetIDValidator(v); err != nil {
- return &ValidationError{Name: "dataset_id", err: fmt.Errorf(`ent: validator failed for field "Agent.dataset_id": %w`, err)}
- }
- }
- if _, ok := ac.mutation.CollectionID(); !ok {
- return &ValidationError{Name: "collection_id", err: errors.New(`ent: missing required field "Agent.collection_id"`)}
- }
- if v, ok := ac.mutation.CollectionID(); ok {
- if err := agent.CollectionIDValidator(v); err != nil {
- return &ValidationError{Name: "collection_id", err: fmt.Errorf(`ent: validator failed for field "Agent.collection_id": %w`, err)}
- }
- }
- return nil
- }
- func (ac *AgentCreate) sqlSave(ctx context.Context) (*Agent, error) {
- if err := ac.check(); err != nil {
- return nil, err
- }
- _node, _spec := ac.createSpec()
- if err := sqlgraph.CreateNode(ctx, ac.driver, _spec); err != nil {
- if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- if _spec.ID.Value != _node.ID {
- id := _spec.ID.Value.(int64)
- _node.ID = uint64(id)
- }
- ac.mutation.id = &_node.ID
- ac.mutation.done = true
- return _node, nil
- }
- func (ac *AgentCreate) createSpec() (*Agent, *sqlgraph.CreateSpec) {
- var (
- _node = &Agent{config: ac.config}
- _spec = sqlgraph.NewCreateSpec(agent.Table, sqlgraph.NewFieldSpec(agent.FieldID, field.TypeUint64))
- )
- _spec.OnConflict = ac.conflict
- if id, ok := ac.mutation.ID(); ok {
- _node.ID = id
- _spec.ID.Value = id
- }
- if value, ok := ac.mutation.CreatedAt(); ok {
- _spec.SetField(agent.FieldCreatedAt, field.TypeTime, value)
- _node.CreatedAt = value
- }
- if value, ok := ac.mutation.UpdatedAt(); ok {
- _spec.SetField(agent.FieldUpdatedAt, field.TypeTime, value)
- _node.UpdatedAt = value
- }
- if value, ok := ac.mutation.DeletedAt(); ok {
- _spec.SetField(agent.FieldDeletedAt, field.TypeTime, value)
- _node.DeletedAt = value
- }
- if value, ok := ac.mutation.Name(); ok {
- _spec.SetField(agent.FieldName, field.TypeString, value)
- _node.Name = value
- }
- if value, ok := ac.mutation.Role(); ok {
- _spec.SetField(agent.FieldRole, field.TypeString, value)
- _node.Role = value
- }
- if value, ok := ac.mutation.Status(); ok {
- _spec.SetField(agent.FieldStatus, field.TypeInt, value)
- _node.Status = value
- }
- if value, ok := ac.mutation.Background(); ok {
- _spec.SetField(agent.FieldBackground, field.TypeString, value)
- _node.Background = value
- }
- if value, ok := ac.mutation.Examples(); ok {
- _spec.SetField(agent.FieldExamples, field.TypeString, value)
- _node.Examples = value
- }
- if value, ok := ac.mutation.OrganizationID(); ok {
- _spec.SetField(agent.FieldOrganizationID, field.TypeUint64, value)
- _node.OrganizationID = value
- }
- if value, ok := ac.mutation.DatasetID(); ok {
- _spec.SetField(agent.FieldDatasetID, field.TypeString, value)
- _node.DatasetID = value
- }
- if value, ok := ac.mutation.CollectionID(); ok {
- _spec.SetField(agent.FieldCollectionID, field.TypeString, value)
- _node.CollectionID = value
- }
- if nodes := ac.mutation.WxAgentIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: agent.WxAgentTable,
- Columns: []string{agent.WxAgentColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(wx.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges = append(_spec.Edges, edge)
- }
- if nodes := ac.mutation.TokenAgentIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: agent.TokenAgentTable,
- Columns: []string{agent.TokenAgentColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(token.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges = append(_spec.Edges, edge)
- }
- if nodes := ac.mutation.WaAgentIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: agent.WaAgentTable,
- Columns: []string{agent.WaAgentColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(whatsapp.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges = append(_spec.Edges, edge)
- }
- if nodes := ac.mutation.KeyAgentIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: agent.KeyAgentTable,
- Columns: []string{agent.KeyAgentColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _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.Agent.Create().
- // SetCreatedAt(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.AgentUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (ac *AgentCreate) OnConflict(opts ...sql.ConflictOption) *AgentUpsertOne {
- ac.conflict = opts
- return &AgentUpsertOne{
- create: ac,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.Agent.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (ac *AgentCreate) OnConflictColumns(columns ...string) *AgentUpsertOne {
- ac.conflict = append(ac.conflict, sql.ConflictColumns(columns...))
- return &AgentUpsertOne{
- create: ac,
- }
- }
- type (
- // AgentUpsertOne is the builder for "upsert"-ing
- // one Agent node.
- AgentUpsertOne struct {
- create *AgentCreate
- }
- // AgentUpsert is the "OnConflict" setter.
- AgentUpsert struct {
- *sql.UpdateSet
- }
- )
- // SetUpdatedAt sets the "updated_at" field.
- func (u *AgentUpsert) SetUpdatedAt(v time.Time) *AgentUpsert {
- u.Set(agent.FieldUpdatedAt, v)
- return u
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *AgentUpsert) UpdateUpdatedAt() *AgentUpsert {
- u.SetExcluded(agent.FieldUpdatedAt)
- return u
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *AgentUpsert) SetDeletedAt(v time.Time) *AgentUpsert {
- u.Set(agent.FieldDeletedAt, v)
- return u
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *AgentUpsert) UpdateDeletedAt() *AgentUpsert {
- u.SetExcluded(agent.FieldDeletedAt)
- return u
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *AgentUpsert) ClearDeletedAt() *AgentUpsert {
- u.SetNull(agent.FieldDeletedAt)
- return u
- }
- // SetName sets the "name" field.
- func (u *AgentUpsert) SetName(v string) *AgentUpsert {
- u.Set(agent.FieldName, v)
- return u
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *AgentUpsert) UpdateName() *AgentUpsert {
- u.SetExcluded(agent.FieldName)
- return u
- }
- // SetRole sets the "role" field.
- func (u *AgentUpsert) SetRole(v string) *AgentUpsert {
- u.Set(agent.FieldRole, v)
- return u
- }
- // UpdateRole sets the "role" field to the value that was provided on create.
- func (u *AgentUpsert) UpdateRole() *AgentUpsert {
- u.SetExcluded(agent.FieldRole)
- return u
- }
- // SetStatus sets the "status" field.
- func (u *AgentUpsert) SetStatus(v int) *AgentUpsert {
- u.Set(agent.FieldStatus, v)
- return u
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *AgentUpsert) UpdateStatus() *AgentUpsert {
- u.SetExcluded(agent.FieldStatus)
- return u
- }
- // AddStatus adds v to the "status" field.
- func (u *AgentUpsert) AddStatus(v int) *AgentUpsert {
- u.Add(agent.FieldStatus, v)
- return u
- }
- // ClearStatus clears the value of the "status" field.
- func (u *AgentUpsert) ClearStatus() *AgentUpsert {
- u.SetNull(agent.FieldStatus)
- return u
- }
- // SetBackground sets the "background" field.
- func (u *AgentUpsert) SetBackground(v string) *AgentUpsert {
- u.Set(agent.FieldBackground, v)
- return u
- }
- // UpdateBackground sets the "background" field to the value that was provided on create.
- func (u *AgentUpsert) UpdateBackground() *AgentUpsert {
- u.SetExcluded(agent.FieldBackground)
- return u
- }
- // ClearBackground clears the value of the "background" field.
- func (u *AgentUpsert) ClearBackground() *AgentUpsert {
- u.SetNull(agent.FieldBackground)
- return u
- }
- // SetExamples sets the "examples" field.
- func (u *AgentUpsert) SetExamples(v string) *AgentUpsert {
- u.Set(agent.FieldExamples, v)
- return u
- }
- // UpdateExamples sets the "examples" field to the value that was provided on create.
- func (u *AgentUpsert) UpdateExamples() *AgentUpsert {
- u.SetExcluded(agent.FieldExamples)
- return u
- }
- // ClearExamples clears the value of the "examples" field.
- func (u *AgentUpsert) ClearExamples() *AgentUpsert {
- u.SetNull(agent.FieldExamples)
- return u
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *AgentUpsert) SetOrganizationID(v uint64) *AgentUpsert {
- u.Set(agent.FieldOrganizationID, v)
- return u
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *AgentUpsert) UpdateOrganizationID() *AgentUpsert {
- u.SetExcluded(agent.FieldOrganizationID)
- return u
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *AgentUpsert) AddOrganizationID(v uint64) *AgentUpsert {
- u.Add(agent.FieldOrganizationID, v)
- return u
- }
- // SetDatasetID sets the "dataset_id" field.
- func (u *AgentUpsert) SetDatasetID(v string) *AgentUpsert {
- u.Set(agent.FieldDatasetID, v)
- return u
- }
- // UpdateDatasetID sets the "dataset_id" field to the value that was provided on create.
- func (u *AgentUpsert) UpdateDatasetID() *AgentUpsert {
- u.SetExcluded(agent.FieldDatasetID)
- return u
- }
- // SetCollectionID sets the "collection_id" field.
- func (u *AgentUpsert) SetCollectionID(v string) *AgentUpsert {
- u.Set(agent.FieldCollectionID, v)
- return u
- }
- // UpdateCollectionID sets the "collection_id" field to the value that was provided on create.
- func (u *AgentUpsert) UpdateCollectionID() *AgentUpsert {
- u.SetExcluded(agent.FieldCollectionID)
- 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.Agent.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(agent.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *AgentUpsertOne) UpdateNewValues() *AgentUpsertOne {
- 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(agent.FieldID)
- }
- if _, exists := u.create.mutation.CreatedAt(); exists {
- s.SetIgnore(agent.FieldCreatedAt)
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.Agent.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *AgentUpsertOne) Ignore() *AgentUpsertOne {
- 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 *AgentUpsertOne) DoNothing() *AgentUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the AgentCreate.OnConflict
- // documentation for more info.
- func (u *AgentUpsertOne) Update(set func(*AgentUpsert)) *AgentUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&AgentUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *AgentUpsertOne) SetUpdatedAt(v time.Time) *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *AgentUpsertOne) UpdateUpdatedAt() *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *AgentUpsertOne) SetDeletedAt(v time.Time) *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *AgentUpsertOne) UpdateDeletedAt() *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *AgentUpsertOne) ClearDeletedAt() *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetName sets the "name" field.
- func (u *AgentUpsertOne) SetName(v string) *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.SetName(v)
- })
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *AgentUpsertOne) UpdateName() *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.UpdateName()
- })
- }
- // SetRole sets the "role" field.
- func (u *AgentUpsertOne) SetRole(v string) *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.SetRole(v)
- })
- }
- // UpdateRole sets the "role" field to the value that was provided on create.
- func (u *AgentUpsertOne) UpdateRole() *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.UpdateRole()
- })
- }
- // SetStatus sets the "status" field.
- func (u *AgentUpsertOne) SetStatus(v int) *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.SetStatus(v)
- })
- }
- // AddStatus adds v to the "status" field.
- func (u *AgentUpsertOne) AddStatus(v int) *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.AddStatus(v)
- })
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *AgentUpsertOne) UpdateStatus() *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.UpdateStatus()
- })
- }
- // ClearStatus clears the value of the "status" field.
- func (u *AgentUpsertOne) ClearStatus() *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.ClearStatus()
- })
- }
- // SetBackground sets the "background" field.
- func (u *AgentUpsertOne) SetBackground(v string) *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.SetBackground(v)
- })
- }
- // UpdateBackground sets the "background" field to the value that was provided on create.
- func (u *AgentUpsertOne) UpdateBackground() *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.UpdateBackground()
- })
- }
- // ClearBackground clears the value of the "background" field.
- func (u *AgentUpsertOne) ClearBackground() *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.ClearBackground()
- })
- }
- // SetExamples sets the "examples" field.
- func (u *AgentUpsertOne) SetExamples(v string) *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.SetExamples(v)
- })
- }
- // UpdateExamples sets the "examples" field to the value that was provided on create.
- func (u *AgentUpsertOne) UpdateExamples() *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.UpdateExamples()
- })
- }
- // ClearExamples clears the value of the "examples" field.
- func (u *AgentUpsertOne) ClearExamples() *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.ClearExamples()
- })
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *AgentUpsertOne) SetOrganizationID(v uint64) *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.SetOrganizationID(v)
- })
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *AgentUpsertOne) AddOrganizationID(v uint64) *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.AddOrganizationID(v)
- })
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *AgentUpsertOne) UpdateOrganizationID() *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.UpdateOrganizationID()
- })
- }
- // SetDatasetID sets the "dataset_id" field.
- func (u *AgentUpsertOne) SetDatasetID(v string) *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.SetDatasetID(v)
- })
- }
- // UpdateDatasetID sets the "dataset_id" field to the value that was provided on create.
- func (u *AgentUpsertOne) UpdateDatasetID() *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.UpdateDatasetID()
- })
- }
- // SetCollectionID sets the "collection_id" field.
- func (u *AgentUpsertOne) SetCollectionID(v string) *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.SetCollectionID(v)
- })
- }
- // UpdateCollectionID sets the "collection_id" field to the value that was provided on create.
- func (u *AgentUpsertOne) UpdateCollectionID() *AgentUpsertOne {
- return u.Update(func(s *AgentUpsert) {
- s.UpdateCollectionID()
- })
- }
- // Exec executes the query.
- func (u *AgentUpsertOne) Exec(ctx context.Context) error {
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for AgentCreate.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *AgentUpsertOne) 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 *AgentUpsertOne) ID(ctx context.Context) (id uint64, err error) {
- 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 *AgentUpsertOne) IDX(ctx context.Context) uint64 {
- id, err := u.ID(ctx)
- if err != nil {
- panic(err)
- }
- return id
- }
- // AgentCreateBulk is the builder for creating many Agent entities in bulk.
- type AgentCreateBulk struct {
- config
- err error
- builders []*AgentCreate
- conflict []sql.ConflictOption
- }
- // Save creates the Agent entities in the database.
- func (acb *AgentCreateBulk) Save(ctx context.Context) ([]*Agent, error) {
- if acb.err != nil {
- return nil, acb.err
- }
- specs := make([]*sqlgraph.CreateSpec, len(acb.builders))
- nodes := make([]*Agent, len(acb.builders))
- mutators := make([]Mutator, len(acb.builders))
- for i := range acb.builders {
- func(i int, root context.Context) {
- builder := acb.builders[i]
- builder.defaults()
- var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
- mutation, ok := m.(*AgentMutation)
- 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, acb.builders[i+1].mutation)
- } else {
- spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
- spec.OnConflict = acb.conflict
- // Invoke the actual operation on the latest mutation in the chain.
- if err = sqlgraph.BatchCreate(ctx, acb.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
- if specs[i].ID.Value != nil && nodes[i].ID == 0 {
- id := specs[i].ID.Value.(int64)
- nodes[i].ID = uint64(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, acb.builders[0].mutation); err != nil {
- return nil, err
- }
- }
- return nodes, nil
- }
- // SaveX is like Save, but panics if an error occurs.
- func (acb *AgentCreateBulk) SaveX(ctx context.Context) []*Agent {
- v, err := acb.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (acb *AgentCreateBulk) Exec(ctx context.Context) error {
- _, err := acb.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (acb *AgentCreateBulk) ExecX(ctx context.Context) {
- if err := acb.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.Agent.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.AgentUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (acb *AgentCreateBulk) OnConflict(opts ...sql.ConflictOption) *AgentUpsertBulk {
- acb.conflict = opts
- return &AgentUpsertBulk{
- create: acb,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.Agent.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (acb *AgentCreateBulk) OnConflictColumns(columns ...string) *AgentUpsertBulk {
- acb.conflict = append(acb.conflict, sql.ConflictColumns(columns...))
- return &AgentUpsertBulk{
- create: acb,
- }
- }
- // AgentUpsertBulk is the builder for "upsert"-ing
- // a bulk of Agent nodes.
- type AgentUpsertBulk struct {
- create *AgentCreateBulk
- }
- // UpdateNewValues updates the mutable fields using the new values that
- // were set on create. Using this option is equivalent to using:
- //
- // client.Agent.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(agent.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *AgentUpsertBulk) UpdateNewValues() *AgentUpsertBulk {
- 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(agent.FieldID)
- }
- if _, exists := b.mutation.CreatedAt(); exists {
- s.SetIgnore(agent.FieldCreatedAt)
- }
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.Agent.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *AgentUpsertBulk) Ignore() *AgentUpsertBulk {
- 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 *AgentUpsertBulk) DoNothing() *AgentUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the AgentCreateBulk.OnConflict
- // documentation for more info.
- func (u *AgentUpsertBulk) Update(set func(*AgentUpsert)) *AgentUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&AgentUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *AgentUpsertBulk) SetUpdatedAt(v time.Time) *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *AgentUpsertBulk) UpdateUpdatedAt() *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *AgentUpsertBulk) SetDeletedAt(v time.Time) *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *AgentUpsertBulk) UpdateDeletedAt() *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *AgentUpsertBulk) ClearDeletedAt() *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetName sets the "name" field.
- func (u *AgentUpsertBulk) SetName(v string) *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.SetName(v)
- })
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *AgentUpsertBulk) UpdateName() *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.UpdateName()
- })
- }
- // SetRole sets the "role" field.
- func (u *AgentUpsertBulk) SetRole(v string) *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.SetRole(v)
- })
- }
- // UpdateRole sets the "role" field to the value that was provided on create.
- func (u *AgentUpsertBulk) UpdateRole() *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.UpdateRole()
- })
- }
- // SetStatus sets the "status" field.
- func (u *AgentUpsertBulk) SetStatus(v int) *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.SetStatus(v)
- })
- }
- // AddStatus adds v to the "status" field.
- func (u *AgentUpsertBulk) AddStatus(v int) *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.AddStatus(v)
- })
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *AgentUpsertBulk) UpdateStatus() *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.UpdateStatus()
- })
- }
- // ClearStatus clears the value of the "status" field.
- func (u *AgentUpsertBulk) ClearStatus() *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.ClearStatus()
- })
- }
- // SetBackground sets the "background" field.
- func (u *AgentUpsertBulk) SetBackground(v string) *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.SetBackground(v)
- })
- }
- // UpdateBackground sets the "background" field to the value that was provided on create.
- func (u *AgentUpsertBulk) UpdateBackground() *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.UpdateBackground()
- })
- }
- // ClearBackground clears the value of the "background" field.
- func (u *AgentUpsertBulk) ClearBackground() *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.ClearBackground()
- })
- }
- // SetExamples sets the "examples" field.
- func (u *AgentUpsertBulk) SetExamples(v string) *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.SetExamples(v)
- })
- }
- // UpdateExamples sets the "examples" field to the value that was provided on create.
- func (u *AgentUpsertBulk) UpdateExamples() *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.UpdateExamples()
- })
- }
- // ClearExamples clears the value of the "examples" field.
- func (u *AgentUpsertBulk) ClearExamples() *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.ClearExamples()
- })
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *AgentUpsertBulk) SetOrganizationID(v uint64) *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.SetOrganizationID(v)
- })
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *AgentUpsertBulk) AddOrganizationID(v uint64) *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.AddOrganizationID(v)
- })
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *AgentUpsertBulk) UpdateOrganizationID() *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.UpdateOrganizationID()
- })
- }
- // SetDatasetID sets the "dataset_id" field.
- func (u *AgentUpsertBulk) SetDatasetID(v string) *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.SetDatasetID(v)
- })
- }
- // UpdateDatasetID sets the "dataset_id" field to the value that was provided on create.
- func (u *AgentUpsertBulk) UpdateDatasetID() *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.UpdateDatasetID()
- })
- }
- // SetCollectionID sets the "collection_id" field.
- func (u *AgentUpsertBulk) SetCollectionID(v string) *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.SetCollectionID(v)
- })
- }
- // UpdateCollectionID sets the "collection_id" field to the value that was provided on create.
- func (u *AgentUpsertBulk) UpdateCollectionID() *AgentUpsertBulk {
- return u.Update(func(s *AgentUpsert) {
- s.UpdateCollectionID()
- })
- }
- // Exec executes the query.
- func (u *AgentUpsertBulk) 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("ent: OnConflict was set for builder %d. Set it on the AgentCreateBulk instead", i)
- }
- }
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for AgentCreateBulk.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *AgentUpsertBulk) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
|