123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560 |
- // 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"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- )
- // SopNodeCreate is the builder for creating a SopNode entity.
- type SopNodeCreate struct {
- config
- mutation *SopNodeMutation
- hooks []Hook
- conflict []sql.ConflictOption
- }
- // SetCreatedAt sets the "created_at" field.
- func (snc *SopNodeCreate) SetCreatedAt(t time.Time) *SopNodeCreate {
- snc.mutation.SetCreatedAt(t)
- return snc
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (snc *SopNodeCreate) SetNillableCreatedAt(t *time.Time) *SopNodeCreate {
- if t != nil {
- snc.SetCreatedAt(*t)
- }
- return snc
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (snc *SopNodeCreate) SetUpdatedAt(t time.Time) *SopNodeCreate {
- snc.mutation.SetUpdatedAt(t)
- return snc
- }
- // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
- func (snc *SopNodeCreate) SetNillableUpdatedAt(t *time.Time) *SopNodeCreate {
- if t != nil {
- snc.SetUpdatedAt(*t)
- }
- return snc
- }
- // SetStatus sets the "status" field.
- func (snc *SopNodeCreate) SetStatus(u uint8) *SopNodeCreate {
- snc.mutation.SetStatus(u)
- return snc
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (snc *SopNodeCreate) SetNillableStatus(u *uint8) *SopNodeCreate {
- if u != nil {
- snc.SetStatus(*u)
- }
- return snc
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (snc *SopNodeCreate) SetDeletedAt(t time.Time) *SopNodeCreate {
- snc.mutation.SetDeletedAt(t)
- return snc
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (snc *SopNodeCreate) SetNillableDeletedAt(t *time.Time) *SopNodeCreate {
- if t != nil {
- snc.SetDeletedAt(*t)
- }
- return snc
- }
- // SetStageID sets the "stage_id" field.
- func (snc *SopNodeCreate) SetStageID(u uint64) *SopNodeCreate {
- snc.mutation.SetStageID(u)
- return snc
- }
- // SetParentID sets the "parent_id" field.
- func (snc *SopNodeCreate) SetParentID(u uint64) *SopNodeCreate {
- snc.mutation.SetParentID(u)
- return snc
- }
- // SetName sets the "name" field.
- func (snc *SopNodeCreate) SetName(s string) *SopNodeCreate {
- snc.mutation.SetName(s)
- return snc
- }
- // SetNillableName sets the "name" field if the given value is not nil.
- func (snc *SopNodeCreate) SetNillableName(s *string) *SopNodeCreate {
- if s != nil {
- snc.SetName(*s)
- }
- return snc
- }
- // SetConditionType sets the "condition_type" field.
- func (snc *SopNodeCreate) SetConditionType(i int) *SopNodeCreate {
- snc.mutation.SetConditionType(i)
- return snc
- }
- // SetNillableConditionType sets the "condition_type" field if the given value is not nil.
- func (snc *SopNodeCreate) SetNillableConditionType(i *int) *SopNodeCreate {
- if i != nil {
- snc.SetConditionType(*i)
- }
- return snc
- }
- // SetConditionList sets the "condition_list" field.
- func (snc *SopNodeCreate) SetConditionList(s []string) *SopNodeCreate {
- snc.mutation.SetConditionList(s)
- return snc
- }
- // SetNoReplyCondition sets the "no_reply_condition" field.
- func (snc *SopNodeCreate) SetNoReplyCondition(u uint64) *SopNodeCreate {
- snc.mutation.SetNoReplyCondition(u)
- return snc
- }
- // SetNillableNoReplyCondition sets the "no_reply_condition" field if the given value is not nil.
- func (snc *SopNodeCreate) SetNillableNoReplyCondition(u *uint64) *SopNodeCreate {
- if u != nil {
- snc.SetNoReplyCondition(*u)
- }
- return snc
- }
- // SetNoReplyUnit sets the "no_reply_unit" field.
- func (snc *SopNodeCreate) SetNoReplyUnit(s string) *SopNodeCreate {
- snc.mutation.SetNoReplyUnit(s)
- return snc
- }
- // SetNillableNoReplyUnit sets the "no_reply_unit" field if the given value is not nil.
- func (snc *SopNodeCreate) SetNillableNoReplyUnit(s *string) *SopNodeCreate {
- if s != nil {
- snc.SetNoReplyUnit(*s)
- }
- return snc
- }
- // SetActionMessage sets the "action_message" field.
- func (snc *SopNodeCreate) SetActionMessage(ct []custom_types.Action) *SopNodeCreate {
- snc.mutation.SetActionMessage(ct)
- return snc
- }
- // SetActionLabelAdd sets the "action_label_add" field.
- func (snc *SopNodeCreate) SetActionLabelAdd(u []uint64) *SopNodeCreate {
- snc.mutation.SetActionLabelAdd(u)
- return snc
- }
- // SetActionLabelDel sets the "action_label_del" field.
- func (snc *SopNodeCreate) SetActionLabelDel(u []uint64) *SopNodeCreate {
- snc.mutation.SetActionLabelDel(u)
- return snc
- }
- // SetActionForward sets the "action_forward" field.
- func (snc *SopNodeCreate) SetActionForward(ctf *custom_types.ActionForward) *SopNodeCreate {
- snc.mutation.SetActionForward(ctf)
- return snc
- }
- // SetID sets the "id" field.
- func (snc *SopNodeCreate) SetID(u uint64) *SopNodeCreate {
- snc.mutation.SetID(u)
- return snc
- }
- // SetSopStageID sets the "sop_stage" edge to the SopStage entity by ID.
- func (snc *SopNodeCreate) SetSopStageID(id uint64) *SopNodeCreate {
- snc.mutation.SetSopStageID(id)
- return snc
- }
- // SetSopStage sets the "sop_stage" edge to the SopStage entity.
- func (snc *SopNodeCreate) SetSopStage(s *SopStage) *SopNodeCreate {
- return snc.SetSopStageID(s.ID)
- }
- // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by IDs.
- func (snc *SopNodeCreate) AddNodeMessageIDs(ids ...uint64) *SopNodeCreate {
- snc.mutation.AddNodeMessageIDs(ids...)
- return snc
- }
- // AddNodeMessages adds the "node_messages" edges to the MessageRecords entity.
- func (snc *SopNodeCreate) AddNodeMessages(m ...*MessageRecords) *SopNodeCreate {
- ids := make([]uint64, len(m))
- for i := range m {
- ids[i] = m[i].ID
- }
- return snc.AddNodeMessageIDs(ids...)
- }
- // Mutation returns the SopNodeMutation object of the builder.
- func (snc *SopNodeCreate) Mutation() *SopNodeMutation {
- return snc.mutation
- }
- // Save creates the SopNode in the database.
- func (snc *SopNodeCreate) Save(ctx context.Context) (*SopNode, error) {
- if err := snc.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, snc.sqlSave, snc.mutation, snc.hooks)
- }
- // SaveX calls Save and panics if Save returns an error.
- func (snc *SopNodeCreate) SaveX(ctx context.Context) *SopNode {
- v, err := snc.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (snc *SopNodeCreate) Exec(ctx context.Context) error {
- _, err := snc.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (snc *SopNodeCreate) ExecX(ctx context.Context) {
- if err := snc.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (snc *SopNodeCreate) defaults() error {
- if _, ok := snc.mutation.CreatedAt(); !ok {
- if sopnode.DefaultCreatedAt == nil {
- return fmt.Errorf("ent: uninitialized sopnode.DefaultCreatedAt (forgotten import ent/runtime?)")
- }
- v := sopnode.DefaultCreatedAt()
- snc.mutation.SetCreatedAt(v)
- }
- if _, ok := snc.mutation.UpdatedAt(); !ok {
- if sopnode.DefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized sopnode.DefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := sopnode.DefaultUpdatedAt()
- snc.mutation.SetUpdatedAt(v)
- }
- if _, ok := snc.mutation.Status(); !ok {
- v := sopnode.DefaultStatus
- snc.mutation.SetStatus(v)
- }
- if _, ok := snc.mutation.Name(); !ok {
- v := sopnode.DefaultName
- snc.mutation.SetName(v)
- }
- if _, ok := snc.mutation.ConditionType(); !ok {
- v := sopnode.DefaultConditionType
- snc.mutation.SetConditionType(v)
- }
- if _, ok := snc.mutation.NoReplyCondition(); !ok {
- v := sopnode.DefaultNoReplyCondition
- snc.mutation.SetNoReplyCondition(v)
- }
- if _, ok := snc.mutation.NoReplyUnit(); !ok {
- v := sopnode.DefaultNoReplyUnit
- snc.mutation.SetNoReplyUnit(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (snc *SopNodeCreate) check() error {
- if _, ok := snc.mutation.CreatedAt(); !ok {
- return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "SopNode.created_at"`)}
- }
- if _, ok := snc.mutation.UpdatedAt(); !ok {
- return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "SopNode.updated_at"`)}
- }
- if _, ok := snc.mutation.StageID(); !ok {
- return &ValidationError{Name: "stage_id", err: errors.New(`ent: missing required field "SopNode.stage_id"`)}
- }
- if _, ok := snc.mutation.ParentID(); !ok {
- return &ValidationError{Name: "parent_id", err: errors.New(`ent: missing required field "SopNode.parent_id"`)}
- }
- if _, ok := snc.mutation.Name(); !ok {
- return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "SopNode.name"`)}
- }
- if _, ok := snc.mutation.ConditionType(); !ok {
- return &ValidationError{Name: "condition_type", err: errors.New(`ent: missing required field "SopNode.condition_type"`)}
- }
- if _, ok := snc.mutation.NoReplyCondition(); !ok {
- return &ValidationError{Name: "no_reply_condition", err: errors.New(`ent: missing required field "SopNode.no_reply_condition"`)}
- }
- if _, ok := snc.mutation.NoReplyUnit(); !ok {
- return &ValidationError{Name: "no_reply_unit", err: errors.New(`ent: missing required field "SopNode.no_reply_unit"`)}
- }
- if _, ok := snc.mutation.SopStageID(); !ok {
- return &ValidationError{Name: "sop_stage", err: errors.New(`ent: missing required edge "SopNode.sop_stage"`)}
- }
- return nil
- }
- func (snc *SopNodeCreate) sqlSave(ctx context.Context) (*SopNode, error) {
- if err := snc.check(); err != nil {
- return nil, err
- }
- _node, _spec := snc.createSpec()
- if err := sqlgraph.CreateNode(ctx, snc.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)
- }
- snc.mutation.id = &_node.ID
- snc.mutation.done = true
- return _node, nil
- }
- func (snc *SopNodeCreate) createSpec() (*SopNode, *sqlgraph.CreateSpec) {
- var (
- _node = &SopNode{config: snc.config}
- _spec = sqlgraph.NewCreateSpec(sopnode.Table, sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64))
- )
- _spec.OnConflict = snc.conflict
- if id, ok := snc.mutation.ID(); ok {
- _node.ID = id
- _spec.ID.Value = id
- }
- if value, ok := snc.mutation.CreatedAt(); ok {
- _spec.SetField(sopnode.FieldCreatedAt, field.TypeTime, value)
- _node.CreatedAt = value
- }
- if value, ok := snc.mutation.UpdatedAt(); ok {
- _spec.SetField(sopnode.FieldUpdatedAt, field.TypeTime, value)
- _node.UpdatedAt = value
- }
- if value, ok := snc.mutation.Status(); ok {
- _spec.SetField(sopnode.FieldStatus, field.TypeUint8, value)
- _node.Status = value
- }
- if value, ok := snc.mutation.DeletedAt(); ok {
- _spec.SetField(sopnode.FieldDeletedAt, field.TypeTime, value)
- _node.DeletedAt = value
- }
- if value, ok := snc.mutation.ParentID(); ok {
- _spec.SetField(sopnode.FieldParentID, field.TypeUint64, value)
- _node.ParentID = value
- }
- if value, ok := snc.mutation.Name(); ok {
- _spec.SetField(sopnode.FieldName, field.TypeString, value)
- _node.Name = value
- }
- if value, ok := snc.mutation.ConditionType(); ok {
- _spec.SetField(sopnode.FieldConditionType, field.TypeInt, value)
- _node.ConditionType = value
- }
- if value, ok := snc.mutation.ConditionList(); ok {
- _spec.SetField(sopnode.FieldConditionList, field.TypeJSON, value)
- _node.ConditionList = value
- }
- if value, ok := snc.mutation.NoReplyCondition(); ok {
- _spec.SetField(sopnode.FieldNoReplyCondition, field.TypeUint64, value)
- _node.NoReplyCondition = value
- }
- if value, ok := snc.mutation.NoReplyUnit(); ok {
- _spec.SetField(sopnode.FieldNoReplyUnit, field.TypeString, value)
- _node.NoReplyUnit = value
- }
- if value, ok := snc.mutation.ActionMessage(); ok {
- _spec.SetField(sopnode.FieldActionMessage, field.TypeJSON, value)
- _node.ActionMessage = value
- }
- if value, ok := snc.mutation.ActionLabelAdd(); ok {
- _spec.SetField(sopnode.FieldActionLabelAdd, field.TypeJSON, value)
- _node.ActionLabelAdd = value
- }
- if value, ok := snc.mutation.ActionLabelDel(); ok {
- _spec.SetField(sopnode.FieldActionLabelDel, field.TypeJSON, value)
- _node.ActionLabelDel = value
- }
- if value, ok := snc.mutation.ActionForward(); ok {
- _spec.SetField(sopnode.FieldActionForward, field.TypeJSON, value)
- _node.ActionForward = value
- }
- if nodes := snc.mutation.SopStageIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: sopnode.SopStageTable,
- Columns: []string{sopnode.SopStageColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopstage.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _node.StageID = nodes[0]
- _spec.Edges = append(_spec.Edges, edge)
- }
- if nodes := snc.mutation.NodeMessagesIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopnode.NodeMessagesTable,
- Columns: []string{sopnode.NodeMessagesColumn},
- 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.SopNode.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.SopNodeUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (snc *SopNodeCreate) OnConflict(opts ...sql.ConflictOption) *SopNodeUpsertOne {
- snc.conflict = opts
- return &SopNodeUpsertOne{
- create: snc,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.SopNode.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (snc *SopNodeCreate) OnConflictColumns(columns ...string) *SopNodeUpsertOne {
- snc.conflict = append(snc.conflict, sql.ConflictColumns(columns...))
- return &SopNodeUpsertOne{
- create: snc,
- }
- }
- type (
- // SopNodeUpsertOne is the builder for "upsert"-ing
- // one SopNode node.
- SopNodeUpsertOne struct {
- create *SopNodeCreate
- }
- // SopNodeUpsert is the "OnConflict" setter.
- SopNodeUpsert struct {
- *sql.UpdateSet
- }
- )
- // SetUpdatedAt sets the "updated_at" field.
- func (u *SopNodeUpsert) SetUpdatedAt(v time.Time) *SopNodeUpsert {
- u.Set(sopnode.FieldUpdatedAt, v)
- return u
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *SopNodeUpsert) UpdateUpdatedAt() *SopNodeUpsert {
- u.SetExcluded(sopnode.FieldUpdatedAt)
- return u
- }
- // SetStatus sets the "status" field.
- func (u *SopNodeUpsert) SetStatus(v uint8) *SopNodeUpsert {
- u.Set(sopnode.FieldStatus, v)
- return u
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *SopNodeUpsert) UpdateStatus() *SopNodeUpsert {
- u.SetExcluded(sopnode.FieldStatus)
- return u
- }
- // AddStatus adds v to the "status" field.
- func (u *SopNodeUpsert) AddStatus(v uint8) *SopNodeUpsert {
- u.Add(sopnode.FieldStatus, v)
- return u
- }
- // ClearStatus clears the value of the "status" field.
- func (u *SopNodeUpsert) ClearStatus() *SopNodeUpsert {
- u.SetNull(sopnode.FieldStatus)
- return u
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *SopNodeUpsert) SetDeletedAt(v time.Time) *SopNodeUpsert {
- u.Set(sopnode.FieldDeletedAt, v)
- return u
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *SopNodeUpsert) UpdateDeletedAt() *SopNodeUpsert {
- u.SetExcluded(sopnode.FieldDeletedAt)
- return u
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *SopNodeUpsert) ClearDeletedAt() *SopNodeUpsert {
- u.SetNull(sopnode.FieldDeletedAt)
- return u
- }
- // SetStageID sets the "stage_id" field.
- func (u *SopNodeUpsert) SetStageID(v uint64) *SopNodeUpsert {
- u.Set(sopnode.FieldStageID, v)
- return u
- }
- // UpdateStageID sets the "stage_id" field to the value that was provided on create.
- func (u *SopNodeUpsert) UpdateStageID() *SopNodeUpsert {
- u.SetExcluded(sopnode.FieldStageID)
- return u
- }
- // SetParentID sets the "parent_id" field.
- func (u *SopNodeUpsert) SetParentID(v uint64) *SopNodeUpsert {
- u.Set(sopnode.FieldParentID, v)
- return u
- }
- // UpdateParentID sets the "parent_id" field to the value that was provided on create.
- func (u *SopNodeUpsert) UpdateParentID() *SopNodeUpsert {
- u.SetExcluded(sopnode.FieldParentID)
- return u
- }
- // AddParentID adds v to the "parent_id" field.
- func (u *SopNodeUpsert) AddParentID(v uint64) *SopNodeUpsert {
- u.Add(sopnode.FieldParentID, v)
- return u
- }
- // SetName sets the "name" field.
- func (u *SopNodeUpsert) SetName(v string) *SopNodeUpsert {
- u.Set(sopnode.FieldName, v)
- return u
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *SopNodeUpsert) UpdateName() *SopNodeUpsert {
- u.SetExcluded(sopnode.FieldName)
- return u
- }
- // SetConditionType sets the "condition_type" field.
- func (u *SopNodeUpsert) SetConditionType(v int) *SopNodeUpsert {
- u.Set(sopnode.FieldConditionType, v)
- return u
- }
- // UpdateConditionType sets the "condition_type" field to the value that was provided on create.
- func (u *SopNodeUpsert) UpdateConditionType() *SopNodeUpsert {
- u.SetExcluded(sopnode.FieldConditionType)
- return u
- }
- // AddConditionType adds v to the "condition_type" field.
- func (u *SopNodeUpsert) AddConditionType(v int) *SopNodeUpsert {
- u.Add(sopnode.FieldConditionType, v)
- return u
- }
- // SetConditionList sets the "condition_list" field.
- func (u *SopNodeUpsert) SetConditionList(v []string) *SopNodeUpsert {
- u.Set(sopnode.FieldConditionList, v)
- return u
- }
- // UpdateConditionList sets the "condition_list" field to the value that was provided on create.
- func (u *SopNodeUpsert) UpdateConditionList() *SopNodeUpsert {
- u.SetExcluded(sopnode.FieldConditionList)
- return u
- }
- // ClearConditionList clears the value of the "condition_list" field.
- func (u *SopNodeUpsert) ClearConditionList() *SopNodeUpsert {
- u.SetNull(sopnode.FieldConditionList)
- return u
- }
- // SetNoReplyCondition sets the "no_reply_condition" field.
- func (u *SopNodeUpsert) SetNoReplyCondition(v uint64) *SopNodeUpsert {
- u.Set(sopnode.FieldNoReplyCondition, v)
- return u
- }
- // UpdateNoReplyCondition sets the "no_reply_condition" field to the value that was provided on create.
- func (u *SopNodeUpsert) UpdateNoReplyCondition() *SopNodeUpsert {
- u.SetExcluded(sopnode.FieldNoReplyCondition)
- return u
- }
- // AddNoReplyCondition adds v to the "no_reply_condition" field.
- func (u *SopNodeUpsert) AddNoReplyCondition(v uint64) *SopNodeUpsert {
- u.Add(sopnode.FieldNoReplyCondition, v)
- return u
- }
- // SetNoReplyUnit sets the "no_reply_unit" field.
- func (u *SopNodeUpsert) SetNoReplyUnit(v string) *SopNodeUpsert {
- u.Set(sopnode.FieldNoReplyUnit, v)
- return u
- }
- // UpdateNoReplyUnit sets the "no_reply_unit" field to the value that was provided on create.
- func (u *SopNodeUpsert) UpdateNoReplyUnit() *SopNodeUpsert {
- u.SetExcluded(sopnode.FieldNoReplyUnit)
- return u
- }
- // SetActionMessage sets the "action_message" field.
- func (u *SopNodeUpsert) SetActionMessage(v []custom_types.Action) *SopNodeUpsert {
- u.Set(sopnode.FieldActionMessage, v)
- return u
- }
- // UpdateActionMessage sets the "action_message" field to the value that was provided on create.
- func (u *SopNodeUpsert) UpdateActionMessage() *SopNodeUpsert {
- u.SetExcluded(sopnode.FieldActionMessage)
- return u
- }
- // ClearActionMessage clears the value of the "action_message" field.
- func (u *SopNodeUpsert) ClearActionMessage() *SopNodeUpsert {
- u.SetNull(sopnode.FieldActionMessage)
- return u
- }
- // SetActionLabelAdd sets the "action_label_add" field.
- func (u *SopNodeUpsert) SetActionLabelAdd(v []uint64) *SopNodeUpsert {
- u.Set(sopnode.FieldActionLabelAdd, v)
- return u
- }
- // UpdateActionLabelAdd sets the "action_label_add" field to the value that was provided on create.
- func (u *SopNodeUpsert) UpdateActionLabelAdd() *SopNodeUpsert {
- u.SetExcluded(sopnode.FieldActionLabelAdd)
- return u
- }
- // ClearActionLabelAdd clears the value of the "action_label_add" field.
- func (u *SopNodeUpsert) ClearActionLabelAdd() *SopNodeUpsert {
- u.SetNull(sopnode.FieldActionLabelAdd)
- return u
- }
- // SetActionLabelDel sets the "action_label_del" field.
- func (u *SopNodeUpsert) SetActionLabelDel(v []uint64) *SopNodeUpsert {
- u.Set(sopnode.FieldActionLabelDel, v)
- return u
- }
- // UpdateActionLabelDel sets the "action_label_del" field to the value that was provided on create.
- func (u *SopNodeUpsert) UpdateActionLabelDel() *SopNodeUpsert {
- u.SetExcluded(sopnode.FieldActionLabelDel)
- return u
- }
- // ClearActionLabelDel clears the value of the "action_label_del" field.
- func (u *SopNodeUpsert) ClearActionLabelDel() *SopNodeUpsert {
- u.SetNull(sopnode.FieldActionLabelDel)
- return u
- }
- // SetActionForward sets the "action_forward" field.
- func (u *SopNodeUpsert) SetActionForward(v *custom_types.ActionForward) *SopNodeUpsert {
- u.Set(sopnode.FieldActionForward, v)
- return u
- }
- // UpdateActionForward sets the "action_forward" field to the value that was provided on create.
- func (u *SopNodeUpsert) UpdateActionForward() *SopNodeUpsert {
- u.SetExcluded(sopnode.FieldActionForward)
- return u
- }
- // ClearActionForward clears the value of the "action_forward" field.
- func (u *SopNodeUpsert) ClearActionForward() *SopNodeUpsert {
- u.SetNull(sopnode.FieldActionForward)
- 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.SopNode.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(sopnode.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *SopNodeUpsertOne) UpdateNewValues() *SopNodeUpsertOne {
- 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(sopnode.FieldID)
- }
- if _, exists := u.create.mutation.CreatedAt(); exists {
- s.SetIgnore(sopnode.FieldCreatedAt)
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.SopNode.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *SopNodeUpsertOne) Ignore() *SopNodeUpsertOne {
- 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 *SopNodeUpsertOne) DoNothing() *SopNodeUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the SopNodeCreate.OnConflict
- // documentation for more info.
- func (u *SopNodeUpsertOne) Update(set func(*SopNodeUpsert)) *SopNodeUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&SopNodeUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *SopNodeUpsertOne) SetUpdatedAt(v time.Time) *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *SopNodeUpsertOne) UpdateUpdatedAt() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetStatus sets the "status" field.
- func (u *SopNodeUpsertOne) SetStatus(v uint8) *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetStatus(v)
- })
- }
- // AddStatus adds v to the "status" field.
- func (u *SopNodeUpsertOne) AddStatus(v uint8) *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.AddStatus(v)
- })
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *SopNodeUpsertOne) UpdateStatus() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateStatus()
- })
- }
- // ClearStatus clears the value of the "status" field.
- func (u *SopNodeUpsertOne) ClearStatus() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.ClearStatus()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *SopNodeUpsertOne) SetDeletedAt(v time.Time) *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *SopNodeUpsertOne) UpdateDeletedAt() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *SopNodeUpsertOne) ClearDeletedAt() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetStageID sets the "stage_id" field.
- func (u *SopNodeUpsertOne) SetStageID(v uint64) *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetStageID(v)
- })
- }
- // UpdateStageID sets the "stage_id" field to the value that was provided on create.
- func (u *SopNodeUpsertOne) UpdateStageID() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateStageID()
- })
- }
- // SetParentID sets the "parent_id" field.
- func (u *SopNodeUpsertOne) SetParentID(v uint64) *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetParentID(v)
- })
- }
- // AddParentID adds v to the "parent_id" field.
- func (u *SopNodeUpsertOne) AddParentID(v uint64) *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.AddParentID(v)
- })
- }
- // UpdateParentID sets the "parent_id" field to the value that was provided on create.
- func (u *SopNodeUpsertOne) UpdateParentID() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateParentID()
- })
- }
- // SetName sets the "name" field.
- func (u *SopNodeUpsertOne) SetName(v string) *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetName(v)
- })
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *SopNodeUpsertOne) UpdateName() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateName()
- })
- }
- // SetConditionType sets the "condition_type" field.
- func (u *SopNodeUpsertOne) SetConditionType(v int) *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetConditionType(v)
- })
- }
- // AddConditionType adds v to the "condition_type" field.
- func (u *SopNodeUpsertOne) AddConditionType(v int) *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.AddConditionType(v)
- })
- }
- // UpdateConditionType sets the "condition_type" field to the value that was provided on create.
- func (u *SopNodeUpsertOne) UpdateConditionType() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateConditionType()
- })
- }
- // SetConditionList sets the "condition_list" field.
- func (u *SopNodeUpsertOne) SetConditionList(v []string) *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetConditionList(v)
- })
- }
- // UpdateConditionList sets the "condition_list" field to the value that was provided on create.
- func (u *SopNodeUpsertOne) UpdateConditionList() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateConditionList()
- })
- }
- // ClearConditionList clears the value of the "condition_list" field.
- func (u *SopNodeUpsertOne) ClearConditionList() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.ClearConditionList()
- })
- }
- // SetNoReplyCondition sets the "no_reply_condition" field.
- func (u *SopNodeUpsertOne) SetNoReplyCondition(v uint64) *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetNoReplyCondition(v)
- })
- }
- // AddNoReplyCondition adds v to the "no_reply_condition" field.
- func (u *SopNodeUpsertOne) AddNoReplyCondition(v uint64) *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.AddNoReplyCondition(v)
- })
- }
- // UpdateNoReplyCondition sets the "no_reply_condition" field to the value that was provided on create.
- func (u *SopNodeUpsertOne) UpdateNoReplyCondition() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateNoReplyCondition()
- })
- }
- // SetNoReplyUnit sets the "no_reply_unit" field.
- func (u *SopNodeUpsertOne) SetNoReplyUnit(v string) *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetNoReplyUnit(v)
- })
- }
- // UpdateNoReplyUnit sets the "no_reply_unit" field to the value that was provided on create.
- func (u *SopNodeUpsertOne) UpdateNoReplyUnit() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateNoReplyUnit()
- })
- }
- // SetActionMessage sets the "action_message" field.
- func (u *SopNodeUpsertOne) SetActionMessage(v []custom_types.Action) *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetActionMessage(v)
- })
- }
- // UpdateActionMessage sets the "action_message" field to the value that was provided on create.
- func (u *SopNodeUpsertOne) UpdateActionMessage() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateActionMessage()
- })
- }
- // ClearActionMessage clears the value of the "action_message" field.
- func (u *SopNodeUpsertOne) ClearActionMessage() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.ClearActionMessage()
- })
- }
- // SetActionLabelAdd sets the "action_label_add" field.
- func (u *SopNodeUpsertOne) SetActionLabelAdd(v []uint64) *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetActionLabelAdd(v)
- })
- }
- // UpdateActionLabelAdd sets the "action_label_add" field to the value that was provided on create.
- func (u *SopNodeUpsertOne) UpdateActionLabelAdd() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateActionLabelAdd()
- })
- }
- // ClearActionLabelAdd clears the value of the "action_label_add" field.
- func (u *SopNodeUpsertOne) ClearActionLabelAdd() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.ClearActionLabelAdd()
- })
- }
- // SetActionLabelDel sets the "action_label_del" field.
- func (u *SopNodeUpsertOne) SetActionLabelDel(v []uint64) *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetActionLabelDel(v)
- })
- }
- // UpdateActionLabelDel sets the "action_label_del" field to the value that was provided on create.
- func (u *SopNodeUpsertOne) UpdateActionLabelDel() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateActionLabelDel()
- })
- }
- // ClearActionLabelDel clears the value of the "action_label_del" field.
- func (u *SopNodeUpsertOne) ClearActionLabelDel() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.ClearActionLabelDel()
- })
- }
- // SetActionForward sets the "action_forward" field.
- func (u *SopNodeUpsertOne) SetActionForward(v *custom_types.ActionForward) *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetActionForward(v)
- })
- }
- // UpdateActionForward sets the "action_forward" field to the value that was provided on create.
- func (u *SopNodeUpsertOne) UpdateActionForward() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateActionForward()
- })
- }
- // ClearActionForward clears the value of the "action_forward" field.
- func (u *SopNodeUpsertOne) ClearActionForward() *SopNodeUpsertOne {
- return u.Update(func(s *SopNodeUpsert) {
- s.ClearActionForward()
- })
- }
- // Exec executes the query.
- func (u *SopNodeUpsertOne) Exec(ctx context.Context) error {
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for SopNodeCreate.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *SopNodeUpsertOne) 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 *SopNodeUpsertOne) 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 *SopNodeUpsertOne) IDX(ctx context.Context) uint64 {
- id, err := u.ID(ctx)
- if err != nil {
- panic(err)
- }
- return id
- }
- // SopNodeCreateBulk is the builder for creating many SopNode entities in bulk.
- type SopNodeCreateBulk struct {
- config
- err error
- builders []*SopNodeCreate
- conflict []sql.ConflictOption
- }
- // Save creates the SopNode entities in the database.
- func (sncb *SopNodeCreateBulk) Save(ctx context.Context) ([]*SopNode, error) {
- if sncb.err != nil {
- return nil, sncb.err
- }
- specs := make([]*sqlgraph.CreateSpec, len(sncb.builders))
- nodes := make([]*SopNode, len(sncb.builders))
- mutators := make([]Mutator, len(sncb.builders))
- for i := range sncb.builders {
- func(i int, root context.Context) {
- builder := sncb.builders[i]
- builder.defaults()
- var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
- mutation, ok := m.(*SopNodeMutation)
- 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, sncb.builders[i+1].mutation)
- } else {
- spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
- spec.OnConflict = sncb.conflict
- // Invoke the actual operation on the latest mutation in the chain.
- if err = sqlgraph.BatchCreate(ctx, sncb.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, sncb.builders[0].mutation); err != nil {
- return nil, err
- }
- }
- return nodes, nil
- }
- // SaveX is like Save, but panics if an error occurs.
- func (sncb *SopNodeCreateBulk) SaveX(ctx context.Context) []*SopNode {
- v, err := sncb.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (sncb *SopNodeCreateBulk) Exec(ctx context.Context) error {
- _, err := sncb.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (sncb *SopNodeCreateBulk) ExecX(ctx context.Context) {
- if err := sncb.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.SopNode.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.SopNodeUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (sncb *SopNodeCreateBulk) OnConflict(opts ...sql.ConflictOption) *SopNodeUpsertBulk {
- sncb.conflict = opts
- return &SopNodeUpsertBulk{
- create: sncb,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.SopNode.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (sncb *SopNodeCreateBulk) OnConflictColumns(columns ...string) *SopNodeUpsertBulk {
- sncb.conflict = append(sncb.conflict, sql.ConflictColumns(columns...))
- return &SopNodeUpsertBulk{
- create: sncb,
- }
- }
- // SopNodeUpsertBulk is the builder for "upsert"-ing
- // a bulk of SopNode nodes.
- type SopNodeUpsertBulk struct {
- create *SopNodeCreateBulk
- }
- // UpdateNewValues updates the mutable fields using the new values that
- // were set on create. Using this option is equivalent to using:
- //
- // client.SopNode.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(sopnode.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *SopNodeUpsertBulk) UpdateNewValues() *SopNodeUpsertBulk {
- 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(sopnode.FieldID)
- }
- if _, exists := b.mutation.CreatedAt(); exists {
- s.SetIgnore(sopnode.FieldCreatedAt)
- }
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.SopNode.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *SopNodeUpsertBulk) Ignore() *SopNodeUpsertBulk {
- 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 *SopNodeUpsertBulk) DoNothing() *SopNodeUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the SopNodeCreateBulk.OnConflict
- // documentation for more info.
- func (u *SopNodeUpsertBulk) Update(set func(*SopNodeUpsert)) *SopNodeUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&SopNodeUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *SopNodeUpsertBulk) SetUpdatedAt(v time.Time) *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *SopNodeUpsertBulk) UpdateUpdatedAt() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetStatus sets the "status" field.
- func (u *SopNodeUpsertBulk) SetStatus(v uint8) *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetStatus(v)
- })
- }
- // AddStatus adds v to the "status" field.
- func (u *SopNodeUpsertBulk) AddStatus(v uint8) *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.AddStatus(v)
- })
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *SopNodeUpsertBulk) UpdateStatus() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateStatus()
- })
- }
- // ClearStatus clears the value of the "status" field.
- func (u *SopNodeUpsertBulk) ClearStatus() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.ClearStatus()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *SopNodeUpsertBulk) SetDeletedAt(v time.Time) *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *SopNodeUpsertBulk) UpdateDeletedAt() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *SopNodeUpsertBulk) ClearDeletedAt() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetStageID sets the "stage_id" field.
- func (u *SopNodeUpsertBulk) SetStageID(v uint64) *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetStageID(v)
- })
- }
- // UpdateStageID sets the "stage_id" field to the value that was provided on create.
- func (u *SopNodeUpsertBulk) UpdateStageID() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateStageID()
- })
- }
- // SetParentID sets the "parent_id" field.
- func (u *SopNodeUpsertBulk) SetParentID(v uint64) *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetParentID(v)
- })
- }
- // AddParentID adds v to the "parent_id" field.
- func (u *SopNodeUpsertBulk) AddParentID(v uint64) *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.AddParentID(v)
- })
- }
- // UpdateParentID sets the "parent_id" field to the value that was provided on create.
- func (u *SopNodeUpsertBulk) UpdateParentID() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateParentID()
- })
- }
- // SetName sets the "name" field.
- func (u *SopNodeUpsertBulk) SetName(v string) *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetName(v)
- })
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *SopNodeUpsertBulk) UpdateName() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateName()
- })
- }
- // SetConditionType sets the "condition_type" field.
- func (u *SopNodeUpsertBulk) SetConditionType(v int) *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetConditionType(v)
- })
- }
- // AddConditionType adds v to the "condition_type" field.
- func (u *SopNodeUpsertBulk) AddConditionType(v int) *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.AddConditionType(v)
- })
- }
- // UpdateConditionType sets the "condition_type" field to the value that was provided on create.
- func (u *SopNodeUpsertBulk) UpdateConditionType() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateConditionType()
- })
- }
- // SetConditionList sets the "condition_list" field.
- func (u *SopNodeUpsertBulk) SetConditionList(v []string) *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetConditionList(v)
- })
- }
- // UpdateConditionList sets the "condition_list" field to the value that was provided on create.
- func (u *SopNodeUpsertBulk) UpdateConditionList() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateConditionList()
- })
- }
- // ClearConditionList clears the value of the "condition_list" field.
- func (u *SopNodeUpsertBulk) ClearConditionList() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.ClearConditionList()
- })
- }
- // SetNoReplyCondition sets the "no_reply_condition" field.
- func (u *SopNodeUpsertBulk) SetNoReplyCondition(v uint64) *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetNoReplyCondition(v)
- })
- }
- // AddNoReplyCondition adds v to the "no_reply_condition" field.
- func (u *SopNodeUpsertBulk) AddNoReplyCondition(v uint64) *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.AddNoReplyCondition(v)
- })
- }
- // UpdateNoReplyCondition sets the "no_reply_condition" field to the value that was provided on create.
- func (u *SopNodeUpsertBulk) UpdateNoReplyCondition() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateNoReplyCondition()
- })
- }
- // SetNoReplyUnit sets the "no_reply_unit" field.
- func (u *SopNodeUpsertBulk) SetNoReplyUnit(v string) *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetNoReplyUnit(v)
- })
- }
- // UpdateNoReplyUnit sets the "no_reply_unit" field to the value that was provided on create.
- func (u *SopNodeUpsertBulk) UpdateNoReplyUnit() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateNoReplyUnit()
- })
- }
- // SetActionMessage sets the "action_message" field.
- func (u *SopNodeUpsertBulk) SetActionMessage(v []custom_types.Action) *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetActionMessage(v)
- })
- }
- // UpdateActionMessage sets the "action_message" field to the value that was provided on create.
- func (u *SopNodeUpsertBulk) UpdateActionMessage() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateActionMessage()
- })
- }
- // ClearActionMessage clears the value of the "action_message" field.
- func (u *SopNodeUpsertBulk) ClearActionMessage() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.ClearActionMessage()
- })
- }
- // SetActionLabelAdd sets the "action_label_add" field.
- func (u *SopNodeUpsertBulk) SetActionLabelAdd(v []uint64) *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetActionLabelAdd(v)
- })
- }
- // UpdateActionLabelAdd sets the "action_label_add" field to the value that was provided on create.
- func (u *SopNodeUpsertBulk) UpdateActionLabelAdd() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateActionLabelAdd()
- })
- }
- // ClearActionLabelAdd clears the value of the "action_label_add" field.
- func (u *SopNodeUpsertBulk) ClearActionLabelAdd() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.ClearActionLabelAdd()
- })
- }
- // SetActionLabelDel sets the "action_label_del" field.
- func (u *SopNodeUpsertBulk) SetActionLabelDel(v []uint64) *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetActionLabelDel(v)
- })
- }
- // UpdateActionLabelDel sets the "action_label_del" field to the value that was provided on create.
- func (u *SopNodeUpsertBulk) UpdateActionLabelDel() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateActionLabelDel()
- })
- }
- // ClearActionLabelDel clears the value of the "action_label_del" field.
- func (u *SopNodeUpsertBulk) ClearActionLabelDel() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.ClearActionLabelDel()
- })
- }
- // SetActionForward sets the "action_forward" field.
- func (u *SopNodeUpsertBulk) SetActionForward(v *custom_types.ActionForward) *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.SetActionForward(v)
- })
- }
- // UpdateActionForward sets the "action_forward" field to the value that was provided on create.
- func (u *SopNodeUpsertBulk) UpdateActionForward() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.UpdateActionForward()
- })
- }
- // ClearActionForward clears the value of the "action_forward" field.
- func (u *SopNodeUpsertBulk) ClearActionForward() *SopNodeUpsertBulk {
- return u.Update(func(s *SopNodeUpsert) {
- s.ClearActionForward()
- })
- }
- // Exec executes the query.
- func (u *SopNodeUpsertBulk) 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 SopNodeCreateBulk instead", i)
- }
- }
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for SopNodeCreateBulk.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *SopNodeUpsertBulk) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
|