123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "wechat-api/ent/custom_types"
- "wechat-api/ent/messagerecords"
- "wechat-api/ent/sopnode"
- "wechat-api/ent/sopstage"
- "wechat-api/ent/soptask"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- )
- // SopStageCreate is the builder for creating a SopStage entity.
- type SopStageCreate struct {
- config
- mutation *SopStageMutation
- hooks []Hook
- conflict []sql.ConflictOption
- }
- // SetCreatedAt sets the "created_at" field.
- func (ssc *SopStageCreate) SetCreatedAt(t time.Time) *SopStageCreate {
- ssc.mutation.SetCreatedAt(t)
- return ssc
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (ssc *SopStageCreate) SetNillableCreatedAt(t *time.Time) *SopStageCreate {
- if t != nil {
- ssc.SetCreatedAt(*t)
- }
- return ssc
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (ssc *SopStageCreate) SetUpdatedAt(t time.Time) *SopStageCreate {
- ssc.mutation.SetUpdatedAt(t)
- return ssc
- }
- // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
- func (ssc *SopStageCreate) SetNillableUpdatedAt(t *time.Time) *SopStageCreate {
- if t != nil {
- ssc.SetUpdatedAt(*t)
- }
- return ssc
- }
- // SetStatus sets the "status" field.
- func (ssc *SopStageCreate) SetStatus(u uint8) *SopStageCreate {
- ssc.mutation.SetStatus(u)
- return ssc
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (ssc *SopStageCreate) SetNillableStatus(u *uint8) *SopStageCreate {
- if u != nil {
- ssc.SetStatus(*u)
- }
- return ssc
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (ssc *SopStageCreate) SetDeletedAt(t time.Time) *SopStageCreate {
- ssc.mutation.SetDeletedAt(t)
- return ssc
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (ssc *SopStageCreate) SetNillableDeletedAt(t *time.Time) *SopStageCreate {
- if t != nil {
- ssc.SetDeletedAt(*t)
- }
- return ssc
- }
- // SetTaskID sets the "task_id" field.
- func (ssc *SopStageCreate) SetTaskID(u uint64) *SopStageCreate {
- ssc.mutation.SetTaskID(u)
- return ssc
- }
- // SetName sets the "name" field.
- func (ssc *SopStageCreate) SetName(s string) *SopStageCreate {
- ssc.mutation.SetName(s)
- return ssc
- }
- // SetNillableName sets the "name" field if the given value is not nil.
- func (ssc *SopStageCreate) SetNillableName(s *string) *SopStageCreate {
- if s != nil {
- ssc.SetName(*s)
- }
- return ssc
- }
- // SetConditionType sets the "condition_type" field.
- func (ssc *SopStageCreate) SetConditionType(i int) *SopStageCreate {
- ssc.mutation.SetConditionType(i)
- return ssc
- }
- // SetNillableConditionType sets the "condition_type" field if the given value is not nil.
- func (ssc *SopStageCreate) SetNillableConditionType(i *int) *SopStageCreate {
- if i != nil {
- ssc.SetConditionType(*i)
- }
- return ssc
- }
- // SetConditionOperator sets the "condition_operator" field.
- func (ssc *SopStageCreate) SetConditionOperator(i int) *SopStageCreate {
- ssc.mutation.SetConditionOperator(i)
- return ssc
- }
- // SetNillableConditionOperator sets the "condition_operator" field if the given value is not nil.
- func (ssc *SopStageCreate) SetNillableConditionOperator(i *int) *SopStageCreate {
- if i != nil {
- ssc.SetConditionOperator(*i)
- }
- return ssc
- }
- // SetConditionList sets the "condition_list" field.
- func (ssc *SopStageCreate) SetConditionList(ct []custom_types.Condition) *SopStageCreate {
- ssc.mutation.SetConditionList(ct)
- return ssc
- }
- // SetActionMessage sets the "action_message" field.
- func (ssc *SopStageCreate) SetActionMessage(ct []custom_types.Action) *SopStageCreate {
- ssc.mutation.SetActionMessage(ct)
- return ssc
- }
- // SetActionLabelAdd sets the "action_label_add" field.
- func (ssc *SopStageCreate) SetActionLabelAdd(u []uint64) *SopStageCreate {
- ssc.mutation.SetActionLabelAdd(u)
- return ssc
- }
- // SetActionLabelDel sets the "action_label_del" field.
- func (ssc *SopStageCreate) SetActionLabelDel(u []uint64) *SopStageCreate {
- ssc.mutation.SetActionLabelDel(u)
- return ssc
- }
- // SetActionForward sets the "action_forward" field.
- func (ssc *SopStageCreate) SetActionForward(ctf *custom_types.ActionForward) *SopStageCreate {
- ssc.mutation.SetActionForward(ctf)
- return ssc
- }
- // SetIndexSort sets the "index_sort" field.
- func (ssc *SopStageCreate) SetIndexSort(i int) *SopStageCreate {
- ssc.mutation.SetIndexSort(i)
- return ssc
- }
- // SetNillableIndexSort sets the "index_sort" field if the given value is not nil.
- func (ssc *SopStageCreate) SetNillableIndexSort(i *int) *SopStageCreate {
- if i != nil {
- ssc.SetIndexSort(*i)
- }
- return ssc
- }
- // SetID sets the "id" field.
- func (ssc *SopStageCreate) SetID(u uint64) *SopStageCreate {
- ssc.mutation.SetID(u)
- return ssc
- }
- // SetSopTaskID sets the "sop_task" edge to the SopTask entity by ID.
- func (ssc *SopStageCreate) SetSopTaskID(id uint64) *SopStageCreate {
- ssc.mutation.SetSopTaskID(id)
- return ssc
- }
- // SetSopTask sets the "sop_task" edge to the SopTask entity.
- func (ssc *SopStageCreate) SetSopTask(s *SopTask) *SopStageCreate {
- return ssc.SetSopTaskID(s.ID)
- }
- // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by IDs.
- func (ssc *SopStageCreate) AddStageNodeIDs(ids ...uint64) *SopStageCreate {
- ssc.mutation.AddStageNodeIDs(ids...)
- return ssc
- }
- // AddStageNodes adds the "stage_nodes" edges to the SopNode entity.
- func (ssc *SopStageCreate) AddStageNodes(s ...*SopNode) *SopStageCreate {
- ids := make([]uint64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return ssc.AddStageNodeIDs(ids...)
- }
- // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by IDs.
- func (ssc *SopStageCreate) AddStageMessageIDs(ids ...uint64) *SopStageCreate {
- ssc.mutation.AddStageMessageIDs(ids...)
- return ssc
- }
- // AddStageMessages adds the "stage_messages" edges to the MessageRecords entity.
- func (ssc *SopStageCreate) AddStageMessages(m ...*MessageRecords) *SopStageCreate {
- ids := make([]uint64, len(m))
- for i := range m {
- ids[i] = m[i].ID
- }
- return ssc.AddStageMessageIDs(ids...)
- }
- // Mutation returns the SopStageMutation object of the builder.
- func (ssc *SopStageCreate) Mutation() *SopStageMutation {
- return ssc.mutation
- }
- // Save creates the SopStage in the database.
- func (ssc *SopStageCreate) Save(ctx context.Context) (*SopStage, error) {
- if err := ssc.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, ssc.sqlSave, ssc.mutation, ssc.hooks)
- }
- // SaveX calls Save and panics if Save returns an error.
- func (ssc *SopStageCreate) SaveX(ctx context.Context) *SopStage {
- v, err := ssc.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (ssc *SopStageCreate) Exec(ctx context.Context) error {
- _, err := ssc.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (ssc *SopStageCreate) ExecX(ctx context.Context) {
- if err := ssc.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (ssc *SopStageCreate) defaults() error {
- if _, ok := ssc.mutation.CreatedAt(); !ok {
- if sopstage.DefaultCreatedAt == nil {
- return fmt.Errorf("ent: uninitialized sopstage.DefaultCreatedAt (forgotten import ent/runtime?)")
- }
- v := sopstage.DefaultCreatedAt()
- ssc.mutation.SetCreatedAt(v)
- }
- if _, ok := ssc.mutation.UpdatedAt(); !ok {
- if sopstage.DefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized sopstage.DefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := sopstage.DefaultUpdatedAt()
- ssc.mutation.SetUpdatedAt(v)
- }
- if _, ok := ssc.mutation.Status(); !ok {
- v := sopstage.DefaultStatus
- ssc.mutation.SetStatus(v)
- }
- if _, ok := ssc.mutation.Name(); !ok {
- v := sopstage.DefaultName
- ssc.mutation.SetName(v)
- }
- if _, ok := ssc.mutation.ConditionType(); !ok {
- v := sopstage.DefaultConditionType
- ssc.mutation.SetConditionType(v)
- }
- if _, ok := ssc.mutation.ConditionOperator(); !ok {
- v := sopstage.DefaultConditionOperator
- ssc.mutation.SetConditionOperator(v)
- }
- if _, ok := ssc.mutation.IndexSort(); !ok {
- v := sopstage.DefaultIndexSort
- ssc.mutation.SetIndexSort(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (ssc *SopStageCreate) check() error {
- if _, ok := ssc.mutation.CreatedAt(); !ok {
- return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "SopStage.created_at"`)}
- }
- if _, ok := ssc.mutation.UpdatedAt(); !ok {
- return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "SopStage.updated_at"`)}
- }
- if _, ok := ssc.mutation.TaskID(); !ok {
- return &ValidationError{Name: "task_id", err: errors.New(`ent: missing required field "SopStage.task_id"`)}
- }
- if _, ok := ssc.mutation.Name(); !ok {
- return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "SopStage.name"`)}
- }
- if _, ok := ssc.mutation.ConditionType(); !ok {
- return &ValidationError{Name: "condition_type", err: errors.New(`ent: missing required field "SopStage.condition_type"`)}
- }
- if _, ok := ssc.mutation.ConditionOperator(); !ok {
- return &ValidationError{Name: "condition_operator", err: errors.New(`ent: missing required field "SopStage.condition_operator"`)}
- }
- if _, ok := ssc.mutation.ConditionList(); !ok {
- return &ValidationError{Name: "condition_list", err: errors.New(`ent: missing required field "SopStage.condition_list"`)}
- }
- if _, ok := ssc.mutation.SopTaskID(); !ok {
- return &ValidationError{Name: "sop_task", err: errors.New(`ent: missing required edge "SopStage.sop_task"`)}
- }
- return nil
- }
- func (ssc *SopStageCreate) sqlSave(ctx context.Context) (*SopStage, error) {
- if err := ssc.check(); err != nil {
- return nil, err
- }
- _node, _spec := ssc.createSpec()
- if err := sqlgraph.CreateNode(ctx, ssc.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)
- }
- ssc.mutation.id = &_node.ID
- ssc.mutation.done = true
- return _node, nil
- }
- func (ssc *SopStageCreate) createSpec() (*SopStage, *sqlgraph.CreateSpec) {
- var (
- _node = &SopStage{config: ssc.config}
- _spec = sqlgraph.NewCreateSpec(sopstage.Table, sqlgraph.NewFieldSpec(sopstage.FieldID, field.TypeUint64))
- )
- _spec.OnConflict = ssc.conflict
- if id, ok := ssc.mutation.ID(); ok {
- _node.ID = id
- _spec.ID.Value = id
- }
- if value, ok := ssc.mutation.CreatedAt(); ok {
- _spec.SetField(sopstage.FieldCreatedAt, field.TypeTime, value)
- _node.CreatedAt = value
- }
- if value, ok := ssc.mutation.UpdatedAt(); ok {
- _spec.SetField(sopstage.FieldUpdatedAt, field.TypeTime, value)
- _node.UpdatedAt = value
- }
- if value, ok := ssc.mutation.Status(); ok {
- _spec.SetField(sopstage.FieldStatus, field.TypeUint8, value)
- _node.Status = value
- }
- if value, ok := ssc.mutation.DeletedAt(); ok {
- _spec.SetField(sopstage.FieldDeletedAt, field.TypeTime, value)
- _node.DeletedAt = value
- }
- if value, ok := ssc.mutation.Name(); ok {
- _spec.SetField(sopstage.FieldName, field.TypeString, value)
- _node.Name = value
- }
- if value, ok := ssc.mutation.ConditionType(); ok {
- _spec.SetField(sopstage.FieldConditionType, field.TypeInt, value)
- _node.ConditionType = value
- }
- if value, ok := ssc.mutation.ConditionOperator(); ok {
- _spec.SetField(sopstage.FieldConditionOperator, field.TypeInt, value)
- _node.ConditionOperator = value
- }
- if value, ok := ssc.mutation.ConditionList(); ok {
- _spec.SetField(sopstage.FieldConditionList, field.TypeJSON, value)
- _node.ConditionList = value
- }
- if value, ok := ssc.mutation.ActionMessage(); ok {
- _spec.SetField(sopstage.FieldActionMessage, field.TypeJSON, value)
- _node.ActionMessage = value
- }
- if value, ok := ssc.mutation.ActionLabelAdd(); ok {
- _spec.SetField(sopstage.FieldActionLabelAdd, field.TypeJSON, value)
- _node.ActionLabelAdd = value
- }
- if value, ok := ssc.mutation.ActionLabelDel(); ok {
- _spec.SetField(sopstage.FieldActionLabelDel, field.TypeJSON, value)
- _node.ActionLabelDel = value
- }
- if value, ok := ssc.mutation.ActionForward(); ok {
- _spec.SetField(sopstage.FieldActionForward, field.TypeJSON, value)
- _node.ActionForward = value
- }
- if value, ok := ssc.mutation.IndexSort(); ok {
- _spec.SetField(sopstage.FieldIndexSort, field.TypeInt, value)
- _node.IndexSort = value
- }
- if nodes := ssc.mutation.SopTaskIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: sopstage.SopTaskTable,
- Columns: []string{sopstage.SopTaskColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(soptask.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _node.TaskID = nodes[0]
- _spec.Edges = append(_spec.Edges, edge)
- }
- if nodes := ssc.mutation.StageNodesIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageNodesTable,
- Columns: []string{sopstage.StageNodesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges = append(_spec.Edges, edge)
- }
- if nodes := ssc.mutation.StageMessagesIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageMessagesTable,
- Columns: []string{sopstage.StageMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.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.SopStage.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.SopStageUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (ssc *SopStageCreate) OnConflict(opts ...sql.ConflictOption) *SopStageUpsertOne {
- ssc.conflict = opts
- return &SopStageUpsertOne{
- create: ssc,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.SopStage.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (ssc *SopStageCreate) OnConflictColumns(columns ...string) *SopStageUpsertOne {
- ssc.conflict = append(ssc.conflict, sql.ConflictColumns(columns...))
- return &SopStageUpsertOne{
- create: ssc,
- }
- }
- type (
- // SopStageUpsertOne is the builder for "upsert"-ing
- // one SopStage node.
- SopStageUpsertOne struct {
- create *SopStageCreate
- }
- // SopStageUpsert is the "OnConflict" setter.
- SopStageUpsert struct {
- *sql.UpdateSet
- }
- )
- // SetUpdatedAt sets the "updated_at" field.
- func (u *SopStageUpsert) SetUpdatedAt(v time.Time) *SopStageUpsert {
- u.Set(sopstage.FieldUpdatedAt, v)
- return u
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *SopStageUpsert) UpdateUpdatedAt() *SopStageUpsert {
- u.SetExcluded(sopstage.FieldUpdatedAt)
- return u
- }
- // SetStatus sets the "status" field.
- func (u *SopStageUpsert) SetStatus(v uint8) *SopStageUpsert {
- u.Set(sopstage.FieldStatus, v)
- return u
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *SopStageUpsert) UpdateStatus() *SopStageUpsert {
- u.SetExcluded(sopstage.FieldStatus)
- return u
- }
- // AddStatus adds v to the "status" field.
- func (u *SopStageUpsert) AddStatus(v uint8) *SopStageUpsert {
- u.Add(sopstage.FieldStatus, v)
- return u
- }
- // ClearStatus clears the value of the "status" field.
- func (u *SopStageUpsert) ClearStatus() *SopStageUpsert {
- u.SetNull(sopstage.FieldStatus)
- return u
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *SopStageUpsert) SetDeletedAt(v time.Time) *SopStageUpsert {
- u.Set(sopstage.FieldDeletedAt, v)
- return u
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *SopStageUpsert) UpdateDeletedAt() *SopStageUpsert {
- u.SetExcluded(sopstage.FieldDeletedAt)
- return u
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *SopStageUpsert) ClearDeletedAt() *SopStageUpsert {
- u.SetNull(sopstage.FieldDeletedAt)
- return u
- }
- // SetTaskID sets the "task_id" field.
- func (u *SopStageUpsert) SetTaskID(v uint64) *SopStageUpsert {
- u.Set(sopstage.FieldTaskID, v)
- return u
- }
- // UpdateTaskID sets the "task_id" field to the value that was provided on create.
- func (u *SopStageUpsert) UpdateTaskID() *SopStageUpsert {
- u.SetExcluded(sopstage.FieldTaskID)
- return u
- }
- // SetName sets the "name" field.
- func (u *SopStageUpsert) SetName(v string) *SopStageUpsert {
- u.Set(sopstage.FieldName, v)
- return u
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *SopStageUpsert) UpdateName() *SopStageUpsert {
- u.SetExcluded(sopstage.FieldName)
- return u
- }
- // SetConditionType sets the "condition_type" field.
- func (u *SopStageUpsert) SetConditionType(v int) *SopStageUpsert {
- u.Set(sopstage.FieldConditionType, v)
- return u
- }
- // UpdateConditionType sets the "condition_type" field to the value that was provided on create.
- func (u *SopStageUpsert) UpdateConditionType() *SopStageUpsert {
- u.SetExcluded(sopstage.FieldConditionType)
- return u
- }
- // AddConditionType adds v to the "condition_type" field.
- func (u *SopStageUpsert) AddConditionType(v int) *SopStageUpsert {
- u.Add(sopstage.FieldConditionType, v)
- return u
- }
- // SetConditionOperator sets the "condition_operator" field.
- func (u *SopStageUpsert) SetConditionOperator(v int) *SopStageUpsert {
- u.Set(sopstage.FieldConditionOperator, v)
- return u
- }
- // UpdateConditionOperator sets the "condition_operator" field to the value that was provided on create.
- func (u *SopStageUpsert) UpdateConditionOperator() *SopStageUpsert {
- u.SetExcluded(sopstage.FieldConditionOperator)
- return u
- }
- // AddConditionOperator adds v to the "condition_operator" field.
- func (u *SopStageUpsert) AddConditionOperator(v int) *SopStageUpsert {
- u.Add(sopstage.FieldConditionOperator, v)
- return u
- }
- // SetConditionList sets the "condition_list" field.
- func (u *SopStageUpsert) SetConditionList(v []custom_types.Condition) *SopStageUpsert {
- u.Set(sopstage.FieldConditionList, v)
- return u
- }
- // UpdateConditionList sets the "condition_list" field to the value that was provided on create.
- func (u *SopStageUpsert) UpdateConditionList() *SopStageUpsert {
- u.SetExcluded(sopstage.FieldConditionList)
- return u
- }
- // SetActionMessage sets the "action_message" field.
- func (u *SopStageUpsert) SetActionMessage(v []custom_types.Action) *SopStageUpsert {
- u.Set(sopstage.FieldActionMessage, v)
- return u
- }
- // UpdateActionMessage sets the "action_message" field to the value that was provided on create.
- func (u *SopStageUpsert) UpdateActionMessage() *SopStageUpsert {
- u.SetExcluded(sopstage.FieldActionMessage)
- return u
- }
- // ClearActionMessage clears the value of the "action_message" field.
- func (u *SopStageUpsert) ClearActionMessage() *SopStageUpsert {
- u.SetNull(sopstage.FieldActionMessage)
- return u
- }
- // SetActionLabelAdd sets the "action_label_add" field.
- func (u *SopStageUpsert) SetActionLabelAdd(v []uint64) *SopStageUpsert {
- u.Set(sopstage.FieldActionLabelAdd, v)
- return u
- }
- // UpdateActionLabelAdd sets the "action_label_add" field to the value that was provided on create.
- func (u *SopStageUpsert) UpdateActionLabelAdd() *SopStageUpsert {
- u.SetExcluded(sopstage.FieldActionLabelAdd)
- return u
- }
- // ClearActionLabelAdd clears the value of the "action_label_add" field.
- func (u *SopStageUpsert) ClearActionLabelAdd() *SopStageUpsert {
- u.SetNull(sopstage.FieldActionLabelAdd)
- return u
- }
- // SetActionLabelDel sets the "action_label_del" field.
- func (u *SopStageUpsert) SetActionLabelDel(v []uint64) *SopStageUpsert {
- u.Set(sopstage.FieldActionLabelDel, v)
- return u
- }
- // UpdateActionLabelDel sets the "action_label_del" field to the value that was provided on create.
- func (u *SopStageUpsert) UpdateActionLabelDel() *SopStageUpsert {
- u.SetExcluded(sopstage.FieldActionLabelDel)
- return u
- }
- // ClearActionLabelDel clears the value of the "action_label_del" field.
- func (u *SopStageUpsert) ClearActionLabelDel() *SopStageUpsert {
- u.SetNull(sopstage.FieldActionLabelDel)
- return u
- }
- // SetActionForward sets the "action_forward" field.
- func (u *SopStageUpsert) SetActionForward(v *custom_types.ActionForward) *SopStageUpsert {
- u.Set(sopstage.FieldActionForward, v)
- return u
- }
- // UpdateActionForward sets the "action_forward" field to the value that was provided on create.
- func (u *SopStageUpsert) UpdateActionForward() *SopStageUpsert {
- u.SetExcluded(sopstage.FieldActionForward)
- return u
- }
- // ClearActionForward clears the value of the "action_forward" field.
- func (u *SopStageUpsert) ClearActionForward() *SopStageUpsert {
- u.SetNull(sopstage.FieldActionForward)
- return u
- }
- // SetIndexSort sets the "index_sort" field.
- func (u *SopStageUpsert) SetIndexSort(v int) *SopStageUpsert {
- u.Set(sopstage.FieldIndexSort, v)
- return u
- }
- // UpdateIndexSort sets the "index_sort" field to the value that was provided on create.
- func (u *SopStageUpsert) UpdateIndexSort() *SopStageUpsert {
- u.SetExcluded(sopstage.FieldIndexSort)
- return u
- }
- // AddIndexSort adds v to the "index_sort" field.
- func (u *SopStageUpsert) AddIndexSort(v int) *SopStageUpsert {
- u.Add(sopstage.FieldIndexSort, v)
- return u
- }
- // ClearIndexSort clears the value of the "index_sort" field.
- func (u *SopStageUpsert) ClearIndexSort() *SopStageUpsert {
- u.SetNull(sopstage.FieldIndexSort)
- 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.SopStage.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(sopstage.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *SopStageUpsertOne) UpdateNewValues() *SopStageUpsertOne {
- 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(sopstage.FieldID)
- }
- if _, exists := u.create.mutation.CreatedAt(); exists {
- s.SetIgnore(sopstage.FieldCreatedAt)
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.SopStage.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *SopStageUpsertOne) Ignore() *SopStageUpsertOne {
- 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 *SopStageUpsertOne) DoNothing() *SopStageUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the SopStageCreate.OnConflict
- // documentation for more info.
- func (u *SopStageUpsertOne) Update(set func(*SopStageUpsert)) *SopStageUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&SopStageUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *SopStageUpsertOne) SetUpdatedAt(v time.Time) *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *SopStageUpsertOne) UpdateUpdatedAt() *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetStatus sets the "status" field.
- func (u *SopStageUpsertOne) SetStatus(v uint8) *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.SetStatus(v)
- })
- }
- // AddStatus adds v to the "status" field.
- func (u *SopStageUpsertOne) AddStatus(v uint8) *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.AddStatus(v)
- })
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *SopStageUpsertOne) UpdateStatus() *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateStatus()
- })
- }
- // ClearStatus clears the value of the "status" field.
- func (u *SopStageUpsertOne) ClearStatus() *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.ClearStatus()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *SopStageUpsertOne) SetDeletedAt(v time.Time) *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *SopStageUpsertOne) UpdateDeletedAt() *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *SopStageUpsertOne) ClearDeletedAt() *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetTaskID sets the "task_id" field.
- func (u *SopStageUpsertOne) SetTaskID(v uint64) *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.SetTaskID(v)
- })
- }
- // UpdateTaskID sets the "task_id" field to the value that was provided on create.
- func (u *SopStageUpsertOne) UpdateTaskID() *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateTaskID()
- })
- }
- // SetName sets the "name" field.
- func (u *SopStageUpsertOne) SetName(v string) *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.SetName(v)
- })
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *SopStageUpsertOne) UpdateName() *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateName()
- })
- }
- // SetConditionType sets the "condition_type" field.
- func (u *SopStageUpsertOne) SetConditionType(v int) *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.SetConditionType(v)
- })
- }
- // AddConditionType adds v to the "condition_type" field.
- func (u *SopStageUpsertOne) AddConditionType(v int) *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.AddConditionType(v)
- })
- }
- // UpdateConditionType sets the "condition_type" field to the value that was provided on create.
- func (u *SopStageUpsertOne) UpdateConditionType() *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateConditionType()
- })
- }
- // SetConditionOperator sets the "condition_operator" field.
- func (u *SopStageUpsertOne) SetConditionOperator(v int) *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.SetConditionOperator(v)
- })
- }
- // AddConditionOperator adds v to the "condition_operator" field.
- func (u *SopStageUpsertOne) AddConditionOperator(v int) *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.AddConditionOperator(v)
- })
- }
- // UpdateConditionOperator sets the "condition_operator" field to the value that was provided on create.
- func (u *SopStageUpsertOne) UpdateConditionOperator() *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateConditionOperator()
- })
- }
- // SetConditionList sets the "condition_list" field.
- func (u *SopStageUpsertOne) SetConditionList(v []custom_types.Condition) *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.SetConditionList(v)
- })
- }
- // UpdateConditionList sets the "condition_list" field to the value that was provided on create.
- func (u *SopStageUpsertOne) UpdateConditionList() *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateConditionList()
- })
- }
- // SetActionMessage sets the "action_message" field.
- func (u *SopStageUpsertOne) SetActionMessage(v []custom_types.Action) *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.SetActionMessage(v)
- })
- }
- // UpdateActionMessage sets the "action_message" field to the value that was provided on create.
- func (u *SopStageUpsertOne) UpdateActionMessage() *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateActionMessage()
- })
- }
- // ClearActionMessage clears the value of the "action_message" field.
- func (u *SopStageUpsertOne) ClearActionMessage() *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.ClearActionMessage()
- })
- }
- // SetActionLabelAdd sets the "action_label_add" field.
- func (u *SopStageUpsertOne) SetActionLabelAdd(v []uint64) *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.SetActionLabelAdd(v)
- })
- }
- // UpdateActionLabelAdd sets the "action_label_add" field to the value that was provided on create.
- func (u *SopStageUpsertOne) UpdateActionLabelAdd() *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateActionLabelAdd()
- })
- }
- // ClearActionLabelAdd clears the value of the "action_label_add" field.
- func (u *SopStageUpsertOne) ClearActionLabelAdd() *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.ClearActionLabelAdd()
- })
- }
- // SetActionLabelDel sets the "action_label_del" field.
- func (u *SopStageUpsertOne) SetActionLabelDel(v []uint64) *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.SetActionLabelDel(v)
- })
- }
- // UpdateActionLabelDel sets the "action_label_del" field to the value that was provided on create.
- func (u *SopStageUpsertOne) UpdateActionLabelDel() *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateActionLabelDel()
- })
- }
- // ClearActionLabelDel clears the value of the "action_label_del" field.
- func (u *SopStageUpsertOne) ClearActionLabelDel() *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.ClearActionLabelDel()
- })
- }
- // SetActionForward sets the "action_forward" field.
- func (u *SopStageUpsertOne) SetActionForward(v *custom_types.ActionForward) *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.SetActionForward(v)
- })
- }
- // UpdateActionForward sets the "action_forward" field to the value that was provided on create.
- func (u *SopStageUpsertOne) UpdateActionForward() *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateActionForward()
- })
- }
- // ClearActionForward clears the value of the "action_forward" field.
- func (u *SopStageUpsertOne) ClearActionForward() *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.ClearActionForward()
- })
- }
- // SetIndexSort sets the "index_sort" field.
- func (u *SopStageUpsertOne) SetIndexSort(v int) *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.SetIndexSort(v)
- })
- }
- // AddIndexSort adds v to the "index_sort" field.
- func (u *SopStageUpsertOne) AddIndexSort(v int) *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.AddIndexSort(v)
- })
- }
- // UpdateIndexSort sets the "index_sort" field to the value that was provided on create.
- func (u *SopStageUpsertOne) UpdateIndexSort() *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateIndexSort()
- })
- }
- // ClearIndexSort clears the value of the "index_sort" field.
- func (u *SopStageUpsertOne) ClearIndexSort() *SopStageUpsertOne {
- return u.Update(func(s *SopStageUpsert) {
- s.ClearIndexSort()
- })
- }
- // Exec executes the query.
- func (u *SopStageUpsertOne) Exec(ctx context.Context) error {
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for SopStageCreate.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *SopStageUpsertOne) 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 *SopStageUpsertOne) 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 *SopStageUpsertOne) IDX(ctx context.Context) uint64 {
- id, err := u.ID(ctx)
- if err != nil {
- panic(err)
- }
- return id
- }
- // SopStageCreateBulk is the builder for creating many SopStage entities in bulk.
- type SopStageCreateBulk struct {
- config
- err error
- builders []*SopStageCreate
- conflict []sql.ConflictOption
- }
- // Save creates the SopStage entities in the database.
- func (sscb *SopStageCreateBulk) Save(ctx context.Context) ([]*SopStage, error) {
- if sscb.err != nil {
- return nil, sscb.err
- }
- specs := make([]*sqlgraph.CreateSpec, len(sscb.builders))
- nodes := make([]*SopStage, len(sscb.builders))
- mutators := make([]Mutator, len(sscb.builders))
- for i := range sscb.builders {
- func(i int, root context.Context) {
- builder := sscb.builders[i]
- builder.defaults()
- var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
- mutation, ok := m.(*SopStageMutation)
- 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, sscb.builders[i+1].mutation)
- } else {
- spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
- spec.OnConflict = sscb.conflict
- // Invoke the actual operation on the latest mutation in the chain.
- if err = sqlgraph.BatchCreate(ctx, sscb.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, sscb.builders[0].mutation); err != nil {
- return nil, err
- }
- }
- return nodes, nil
- }
- // SaveX is like Save, but panics if an error occurs.
- func (sscb *SopStageCreateBulk) SaveX(ctx context.Context) []*SopStage {
- v, err := sscb.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (sscb *SopStageCreateBulk) Exec(ctx context.Context) error {
- _, err := sscb.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (sscb *SopStageCreateBulk) ExecX(ctx context.Context) {
- if err := sscb.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.SopStage.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.SopStageUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (sscb *SopStageCreateBulk) OnConflict(opts ...sql.ConflictOption) *SopStageUpsertBulk {
- sscb.conflict = opts
- return &SopStageUpsertBulk{
- create: sscb,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.SopStage.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (sscb *SopStageCreateBulk) OnConflictColumns(columns ...string) *SopStageUpsertBulk {
- sscb.conflict = append(sscb.conflict, sql.ConflictColumns(columns...))
- return &SopStageUpsertBulk{
- create: sscb,
- }
- }
- // SopStageUpsertBulk is the builder for "upsert"-ing
- // a bulk of SopStage nodes.
- type SopStageUpsertBulk struct {
- create *SopStageCreateBulk
- }
- // UpdateNewValues updates the mutable fields using the new values that
- // were set on create. Using this option is equivalent to using:
- //
- // client.SopStage.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(sopstage.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *SopStageUpsertBulk) UpdateNewValues() *SopStageUpsertBulk {
- 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(sopstage.FieldID)
- }
- if _, exists := b.mutation.CreatedAt(); exists {
- s.SetIgnore(sopstage.FieldCreatedAt)
- }
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.SopStage.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *SopStageUpsertBulk) Ignore() *SopStageUpsertBulk {
- 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 *SopStageUpsertBulk) DoNothing() *SopStageUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the SopStageCreateBulk.OnConflict
- // documentation for more info.
- func (u *SopStageUpsertBulk) Update(set func(*SopStageUpsert)) *SopStageUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&SopStageUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *SopStageUpsertBulk) SetUpdatedAt(v time.Time) *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *SopStageUpsertBulk) UpdateUpdatedAt() *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetStatus sets the "status" field.
- func (u *SopStageUpsertBulk) SetStatus(v uint8) *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.SetStatus(v)
- })
- }
- // AddStatus adds v to the "status" field.
- func (u *SopStageUpsertBulk) AddStatus(v uint8) *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.AddStatus(v)
- })
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *SopStageUpsertBulk) UpdateStatus() *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateStatus()
- })
- }
- // ClearStatus clears the value of the "status" field.
- func (u *SopStageUpsertBulk) ClearStatus() *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.ClearStatus()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *SopStageUpsertBulk) SetDeletedAt(v time.Time) *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *SopStageUpsertBulk) UpdateDeletedAt() *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *SopStageUpsertBulk) ClearDeletedAt() *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetTaskID sets the "task_id" field.
- func (u *SopStageUpsertBulk) SetTaskID(v uint64) *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.SetTaskID(v)
- })
- }
- // UpdateTaskID sets the "task_id" field to the value that was provided on create.
- func (u *SopStageUpsertBulk) UpdateTaskID() *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateTaskID()
- })
- }
- // SetName sets the "name" field.
- func (u *SopStageUpsertBulk) SetName(v string) *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.SetName(v)
- })
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *SopStageUpsertBulk) UpdateName() *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateName()
- })
- }
- // SetConditionType sets the "condition_type" field.
- func (u *SopStageUpsertBulk) SetConditionType(v int) *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.SetConditionType(v)
- })
- }
- // AddConditionType adds v to the "condition_type" field.
- func (u *SopStageUpsertBulk) AddConditionType(v int) *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.AddConditionType(v)
- })
- }
- // UpdateConditionType sets the "condition_type" field to the value that was provided on create.
- func (u *SopStageUpsertBulk) UpdateConditionType() *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateConditionType()
- })
- }
- // SetConditionOperator sets the "condition_operator" field.
- func (u *SopStageUpsertBulk) SetConditionOperator(v int) *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.SetConditionOperator(v)
- })
- }
- // AddConditionOperator adds v to the "condition_operator" field.
- func (u *SopStageUpsertBulk) AddConditionOperator(v int) *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.AddConditionOperator(v)
- })
- }
- // UpdateConditionOperator sets the "condition_operator" field to the value that was provided on create.
- func (u *SopStageUpsertBulk) UpdateConditionOperator() *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateConditionOperator()
- })
- }
- // SetConditionList sets the "condition_list" field.
- func (u *SopStageUpsertBulk) SetConditionList(v []custom_types.Condition) *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.SetConditionList(v)
- })
- }
- // UpdateConditionList sets the "condition_list" field to the value that was provided on create.
- func (u *SopStageUpsertBulk) UpdateConditionList() *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateConditionList()
- })
- }
- // SetActionMessage sets the "action_message" field.
- func (u *SopStageUpsertBulk) SetActionMessage(v []custom_types.Action) *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.SetActionMessage(v)
- })
- }
- // UpdateActionMessage sets the "action_message" field to the value that was provided on create.
- func (u *SopStageUpsertBulk) UpdateActionMessage() *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateActionMessage()
- })
- }
- // ClearActionMessage clears the value of the "action_message" field.
- func (u *SopStageUpsertBulk) ClearActionMessage() *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.ClearActionMessage()
- })
- }
- // SetActionLabelAdd sets the "action_label_add" field.
- func (u *SopStageUpsertBulk) SetActionLabelAdd(v []uint64) *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.SetActionLabelAdd(v)
- })
- }
- // UpdateActionLabelAdd sets the "action_label_add" field to the value that was provided on create.
- func (u *SopStageUpsertBulk) UpdateActionLabelAdd() *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateActionLabelAdd()
- })
- }
- // ClearActionLabelAdd clears the value of the "action_label_add" field.
- func (u *SopStageUpsertBulk) ClearActionLabelAdd() *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.ClearActionLabelAdd()
- })
- }
- // SetActionLabelDel sets the "action_label_del" field.
- func (u *SopStageUpsertBulk) SetActionLabelDel(v []uint64) *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.SetActionLabelDel(v)
- })
- }
- // UpdateActionLabelDel sets the "action_label_del" field to the value that was provided on create.
- func (u *SopStageUpsertBulk) UpdateActionLabelDel() *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateActionLabelDel()
- })
- }
- // ClearActionLabelDel clears the value of the "action_label_del" field.
- func (u *SopStageUpsertBulk) ClearActionLabelDel() *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.ClearActionLabelDel()
- })
- }
- // SetActionForward sets the "action_forward" field.
- func (u *SopStageUpsertBulk) SetActionForward(v *custom_types.ActionForward) *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.SetActionForward(v)
- })
- }
- // UpdateActionForward sets the "action_forward" field to the value that was provided on create.
- func (u *SopStageUpsertBulk) UpdateActionForward() *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateActionForward()
- })
- }
- // ClearActionForward clears the value of the "action_forward" field.
- func (u *SopStageUpsertBulk) ClearActionForward() *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.ClearActionForward()
- })
- }
- // SetIndexSort sets the "index_sort" field.
- func (u *SopStageUpsertBulk) SetIndexSort(v int) *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.SetIndexSort(v)
- })
- }
- // AddIndexSort adds v to the "index_sort" field.
- func (u *SopStageUpsertBulk) AddIndexSort(v int) *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.AddIndexSort(v)
- })
- }
- // UpdateIndexSort sets the "index_sort" field to the value that was provided on create.
- func (u *SopStageUpsertBulk) UpdateIndexSort() *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.UpdateIndexSort()
- })
- }
- // ClearIndexSort clears the value of the "index_sort" field.
- func (u *SopStageUpsertBulk) ClearIndexSort() *SopStageUpsertBulk {
- return u.Update(func(s *SopStageUpsert) {
- s.ClearIndexSort()
- })
- }
- // Exec executes the query.
- func (u *SopStageUpsertBulk) 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 SopStageCreateBulk instead", i)
- }
- }
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for SopStageCreateBulk.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *SopStageUpsertBulk) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
|