12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "wechat-api/ent/sopstage"
- "wechat-api/ent/soptask"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- )
- // SopTaskCreate is the builder for creating a SopTask entity.
- type SopTaskCreate struct {
- config
- mutation *SopTaskMutation
- hooks []Hook
- conflict []sql.ConflictOption
- }
- // SetCreatedAt sets the "created_at" field.
- func (stc *SopTaskCreate) SetCreatedAt(t time.Time) *SopTaskCreate {
- stc.mutation.SetCreatedAt(t)
- return stc
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (stc *SopTaskCreate) SetNillableCreatedAt(t *time.Time) *SopTaskCreate {
- if t != nil {
- stc.SetCreatedAt(*t)
- }
- return stc
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (stc *SopTaskCreate) SetUpdatedAt(t time.Time) *SopTaskCreate {
- stc.mutation.SetUpdatedAt(t)
- return stc
- }
- // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
- func (stc *SopTaskCreate) SetNillableUpdatedAt(t *time.Time) *SopTaskCreate {
- if t != nil {
- stc.SetUpdatedAt(*t)
- }
- return stc
- }
- // SetStatus sets the "status" field.
- func (stc *SopTaskCreate) SetStatus(u uint8) *SopTaskCreate {
- stc.mutation.SetStatus(u)
- return stc
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (stc *SopTaskCreate) SetNillableStatus(u *uint8) *SopTaskCreate {
- if u != nil {
- stc.SetStatus(*u)
- }
- return stc
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (stc *SopTaskCreate) SetDeletedAt(t time.Time) *SopTaskCreate {
- stc.mutation.SetDeletedAt(t)
- return stc
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (stc *SopTaskCreate) SetNillableDeletedAt(t *time.Time) *SopTaskCreate {
- if t != nil {
- stc.SetDeletedAt(*t)
- }
- return stc
- }
- // SetName sets the "name" field.
- func (stc *SopTaskCreate) SetName(s string) *SopTaskCreate {
- stc.mutation.SetName(s)
- return stc
- }
- // SetBotWxidList sets the "bot_wxid_list" field.
- func (stc *SopTaskCreate) SetBotWxidList(s []string) *SopTaskCreate {
- stc.mutation.SetBotWxidList(s)
- return stc
- }
- // SetType sets the "type" field.
- func (stc *SopTaskCreate) SetType(i int) *SopTaskCreate {
- stc.mutation.SetType(i)
- return stc
- }
- // SetNillableType sets the "type" field if the given value is not nil.
- func (stc *SopTaskCreate) SetNillableType(i *int) *SopTaskCreate {
- if i != nil {
- stc.SetType(*i)
- }
- return stc
- }
- // SetPlanStartTime sets the "plan_start_time" field.
- func (stc *SopTaskCreate) SetPlanStartTime(t time.Time) *SopTaskCreate {
- stc.mutation.SetPlanStartTime(t)
- return stc
- }
- // SetNillablePlanStartTime sets the "plan_start_time" field if the given value is not nil.
- func (stc *SopTaskCreate) SetNillablePlanStartTime(t *time.Time) *SopTaskCreate {
- if t != nil {
- stc.SetPlanStartTime(*t)
- }
- return stc
- }
- // SetPlanEndTime sets the "plan_end_time" field.
- func (stc *SopTaskCreate) SetPlanEndTime(t time.Time) *SopTaskCreate {
- stc.mutation.SetPlanEndTime(t)
- return stc
- }
- // SetNillablePlanEndTime sets the "plan_end_time" field if the given value is not nil.
- func (stc *SopTaskCreate) SetNillablePlanEndTime(t *time.Time) *SopTaskCreate {
- if t != nil {
- stc.SetPlanEndTime(*t)
- }
- return stc
- }
- // SetCreatorID sets the "creator_id" field.
- func (stc *SopTaskCreate) SetCreatorID(s string) *SopTaskCreate {
- stc.mutation.SetCreatorID(s)
- return stc
- }
- // SetNillableCreatorID sets the "creator_id" field if the given value is not nil.
- func (stc *SopTaskCreate) SetNillableCreatorID(s *string) *SopTaskCreate {
- if s != nil {
- stc.SetCreatorID(*s)
- }
- return stc
- }
- // SetOrganizationID sets the "organization_id" field.
- func (stc *SopTaskCreate) SetOrganizationID(u uint64) *SopTaskCreate {
- stc.mutation.SetOrganizationID(u)
- return stc
- }
- // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
- func (stc *SopTaskCreate) SetNillableOrganizationID(u *uint64) *SopTaskCreate {
- if u != nil {
- stc.SetOrganizationID(*u)
- }
- return stc
- }
- // SetID sets the "id" field.
- func (stc *SopTaskCreate) SetID(u uint64) *SopTaskCreate {
- stc.mutation.SetID(u)
- return stc
- }
- // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by IDs.
- func (stc *SopTaskCreate) AddTaskStageIDs(ids ...uint64) *SopTaskCreate {
- stc.mutation.AddTaskStageIDs(ids...)
- return stc
- }
- // AddTaskStages adds the "task_stages" edges to the SopStage entity.
- func (stc *SopTaskCreate) AddTaskStages(s ...*SopStage) *SopTaskCreate {
- ids := make([]uint64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return stc.AddTaskStageIDs(ids...)
- }
- // Mutation returns the SopTaskMutation object of the builder.
- func (stc *SopTaskCreate) Mutation() *SopTaskMutation {
- return stc.mutation
- }
- // Save creates the SopTask in the database.
- func (stc *SopTaskCreate) Save(ctx context.Context) (*SopTask, error) {
- if err := stc.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, stc.sqlSave, stc.mutation, stc.hooks)
- }
- // SaveX calls Save and panics if Save returns an error.
- func (stc *SopTaskCreate) SaveX(ctx context.Context) *SopTask {
- v, err := stc.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (stc *SopTaskCreate) Exec(ctx context.Context) error {
- _, err := stc.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (stc *SopTaskCreate) ExecX(ctx context.Context) {
- if err := stc.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (stc *SopTaskCreate) defaults() error {
- if _, ok := stc.mutation.CreatedAt(); !ok {
- if soptask.DefaultCreatedAt == nil {
- return fmt.Errorf("ent: uninitialized soptask.DefaultCreatedAt (forgotten import ent/runtime?)")
- }
- v := soptask.DefaultCreatedAt()
- stc.mutation.SetCreatedAt(v)
- }
- if _, ok := stc.mutation.UpdatedAt(); !ok {
- if soptask.DefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized soptask.DefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := soptask.DefaultUpdatedAt()
- stc.mutation.SetUpdatedAt(v)
- }
- if _, ok := stc.mutation.Status(); !ok {
- v := soptask.DefaultStatus
- stc.mutation.SetStatus(v)
- }
- if _, ok := stc.mutation.GetType(); !ok {
- v := soptask.DefaultType
- stc.mutation.SetType(v)
- }
- if _, ok := stc.mutation.OrganizationID(); !ok {
- v := soptask.DefaultOrganizationID
- stc.mutation.SetOrganizationID(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (stc *SopTaskCreate) check() error {
- if _, ok := stc.mutation.CreatedAt(); !ok {
- return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "SopTask.created_at"`)}
- }
- if _, ok := stc.mutation.UpdatedAt(); !ok {
- return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "SopTask.updated_at"`)}
- }
- if _, ok := stc.mutation.Name(); !ok {
- return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "SopTask.name"`)}
- }
- if v, ok := stc.mutation.Name(); ok {
- if err := soptask.NameValidator(v); err != nil {
- return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "SopTask.name": %w`, err)}
- }
- }
- if _, ok := stc.mutation.GetType(); !ok {
- return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "SopTask.type"`)}
- }
- return nil
- }
- func (stc *SopTaskCreate) sqlSave(ctx context.Context) (*SopTask, error) {
- if err := stc.check(); err != nil {
- return nil, err
- }
- _node, _spec := stc.createSpec()
- if err := sqlgraph.CreateNode(ctx, stc.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)
- }
- stc.mutation.id = &_node.ID
- stc.mutation.done = true
- return _node, nil
- }
- func (stc *SopTaskCreate) createSpec() (*SopTask, *sqlgraph.CreateSpec) {
- var (
- _node = &SopTask{config: stc.config}
- _spec = sqlgraph.NewCreateSpec(soptask.Table, sqlgraph.NewFieldSpec(soptask.FieldID, field.TypeUint64))
- )
- _spec.OnConflict = stc.conflict
- if id, ok := stc.mutation.ID(); ok {
- _node.ID = id
- _spec.ID.Value = id
- }
- if value, ok := stc.mutation.CreatedAt(); ok {
- _spec.SetField(soptask.FieldCreatedAt, field.TypeTime, value)
- _node.CreatedAt = value
- }
- if value, ok := stc.mutation.UpdatedAt(); ok {
- _spec.SetField(soptask.FieldUpdatedAt, field.TypeTime, value)
- _node.UpdatedAt = value
- }
- if value, ok := stc.mutation.Status(); ok {
- _spec.SetField(soptask.FieldStatus, field.TypeUint8, value)
- _node.Status = value
- }
- if value, ok := stc.mutation.DeletedAt(); ok {
- _spec.SetField(soptask.FieldDeletedAt, field.TypeTime, value)
- _node.DeletedAt = value
- }
- if value, ok := stc.mutation.Name(); ok {
- _spec.SetField(soptask.FieldName, field.TypeString, value)
- _node.Name = value
- }
- if value, ok := stc.mutation.BotWxidList(); ok {
- _spec.SetField(soptask.FieldBotWxidList, field.TypeJSON, value)
- _node.BotWxidList = value
- }
- if value, ok := stc.mutation.GetType(); ok {
- _spec.SetField(soptask.FieldType, field.TypeInt, value)
- _node.Type = value
- }
- if value, ok := stc.mutation.PlanStartTime(); ok {
- _spec.SetField(soptask.FieldPlanStartTime, field.TypeTime, value)
- _node.PlanStartTime = value
- }
- if value, ok := stc.mutation.PlanEndTime(); ok {
- _spec.SetField(soptask.FieldPlanEndTime, field.TypeTime, value)
- _node.PlanEndTime = value
- }
- if value, ok := stc.mutation.CreatorID(); ok {
- _spec.SetField(soptask.FieldCreatorID, field.TypeString, value)
- _node.CreatorID = value
- }
- if value, ok := stc.mutation.OrganizationID(); ok {
- _spec.SetField(soptask.FieldOrganizationID, field.TypeUint64, value)
- _node.OrganizationID = value
- }
- if nodes := stc.mutation.TaskStagesIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: soptask.TaskStagesTable,
- Columns: []string{soptask.TaskStagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopstage.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.SopTask.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.SopTaskUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (stc *SopTaskCreate) OnConflict(opts ...sql.ConflictOption) *SopTaskUpsertOne {
- stc.conflict = opts
- return &SopTaskUpsertOne{
- create: stc,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.SopTask.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (stc *SopTaskCreate) OnConflictColumns(columns ...string) *SopTaskUpsertOne {
- stc.conflict = append(stc.conflict, sql.ConflictColumns(columns...))
- return &SopTaskUpsertOne{
- create: stc,
- }
- }
- type (
- // SopTaskUpsertOne is the builder for "upsert"-ing
- // one SopTask node.
- SopTaskUpsertOne struct {
- create *SopTaskCreate
- }
- // SopTaskUpsert is the "OnConflict" setter.
- SopTaskUpsert struct {
- *sql.UpdateSet
- }
- )
- // SetUpdatedAt sets the "updated_at" field.
- func (u *SopTaskUpsert) SetUpdatedAt(v time.Time) *SopTaskUpsert {
- u.Set(soptask.FieldUpdatedAt, v)
- return u
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *SopTaskUpsert) UpdateUpdatedAt() *SopTaskUpsert {
- u.SetExcluded(soptask.FieldUpdatedAt)
- return u
- }
- // SetStatus sets the "status" field.
- func (u *SopTaskUpsert) SetStatus(v uint8) *SopTaskUpsert {
- u.Set(soptask.FieldStatus, v)
- return u
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *SopTaskUpsert) UpdateStatus() *SopTaskUpsert {
- u.SetExcluded(soptask.FieldStatus)
- return u
- }
- // AddStatus adds v to the "status" field.
- func (u *SopTaskUpsert) AddStatus(v uint8) *SopTaskUpsert {
- u.Add(soptask.FieldStatus, v)
- return u
- }
- // ClearStatus clears the value of the "status" field.
- func (u *SopTaskUpsert) ClearStatus() *SopTaskUpsert {
- u.SetNull(soptask.FieldStatus)
- return u
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *SopTaskUpsert) SetDeletedAt(v time.Time) *SopTaskUpsert {
- u.Set(soptask.FieldDeletedAt, v)
- return u
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *SopTaskUpsert) UpdateDeletedAt() *SopTaskUpsert {
- u.SetExcluded(soptask.FieldDeletedAt)
- return u
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *SopTaskUpsert) ClearDeletedAt() *SopTaskUpsert {
- u.SetNull(soptask.FieldDeletedAt)
- return u
- }
- // SetName sets the "name" field.
- func (u *SopTaskUpsert) SetName(v string) *SopTaskUpsert {
- u.Set(soptask.FieldName, v)
- return u
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *SopTaskUpsert) UpdateName() *SopTaskUpsert {
- u.SetExcluded(soptask.FieldName)
- return u
- }
- // SetBotWxidList sets the "bot_wxid_list" field.
- func (u *SopTaskUpsert) SetBotWxidList(v []string) *SopTaskUpsert {
- u.Set(soptask.FieldBotWxidList, v)
- return u
- }
- // UpdateBotWxidList sets the "bot_wxid_list" field to the value that was provided on create.
- func (u *SopTaskUpsert) UpdateBotWxidList() *SopTaskUpsert {
- u.SetExcluded(soptask.FieldBotWxidList)
- return u
- }
- // ClearBotWxidList clears the value of the "bot_wxid_list" field.
- func (u *SopTaskUpsert) ClearBotWxidList() *SopTaskUpsert {
- u.SetNull(soptask.FieldBotWxidList)
- return u
- }
- // SetType sets the "type" field.
- func (u *SopTaskUpsert) SetType(v int) *SopTaskUpsert {
- u.Set(soptask.FieldType, v)
- return u
- }
- // UpdateType sets the "type" field to the value that was provided on create.
- func (u *SopTaskUpsert) UpdateType() *SopTaskUpsert {
- u.SetExcluded(soptask.FieldType)
- return u
- }
- // AddType adds v to the "type" field.
- func (u *SopTaskUpsert) AddType(v int) *SopTaskUpsert {
- u.Add(soptask.FieldType, v)
- return u
- }
- // SetPlanStartTime sets the "plan_start_time" field.
- func (u *SopTaskUpsert) SetPlanStartTime(v time.Time) *SopTaskUpsert {
- u.Set(soptask.FieldPlanStartTime, v)
- return u
- }
- // UpdatePlanStartTime sets the "plan_start_time" field to the value that was provided on create.
- func (u *SopTaskUpsert) UpdatePlanStartTime() *SopTaskUpsert {
- u.SetExcluded(soptask.FieldPlanStartTime)
- return u
- }
- // ClearPlanStartTime clears the value of the "plan_start_time" field.
- func (u *SopTaskUpsert) ClearPlanStartTime() *SopTaskUpsert {
- u.SetNull(soptask.FieldPlanStartTime)
- return u
- }
- // SetPlanEndTime sets the "plan_end_time" field.
- func (u *SopTaskUpsert) SetPlanEndTime(v time.Time) *SopTaskUpsert {
- u.Set(soptask.FieldPlanEndTime, v)
- return u
- }
- // UpdatePlanEndTime sets the "plan_end_time" field to the value that was provided on create.
- func (u *SopTaskUpsert) UpdatePlanEndTime() *SopTaskUpsert {
- u.SetExcluded(soptask.FieldPlanEndTime)
- return u
- }
- // ClearPlanEndTime clears the value of the "plan_end_time" field.
- func (u *SopTaskUpsert) ClearPlanEndTime() *SopTaskUpsert {
- u.SetNull(soptask.FieldPlanEndTime)
- return u
- }
- // SetCreatorID sets the "creator_id" field.
- func (u *SopTaskUpsert) SetCreatorID(v string) *SopTaskUpsert {
- u.Set(soptask.FieldCreatorID, v)
- return u
- }
- // UpdateCreatorID sets the "creator_id" field to the value that was provided on create.
- func (u *SopTaskUpsert) UpdateCreatorID() *SopTaskUpsert {
- u.SetExcluded(soptask.FieldCreatorID)
- return u
- }
- // ClearCreatorID clears the value of the "creator_id" field.
- func (u *SopTaskUpsert) ClearCreatorID() *SopTaskUpsert {
- u.SetNull(soptask.FieldCreatorID)
- return u
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *SopTaskUpsert) SetOrganizationID(v uint64) *SopTaskUpsert {
- u.Set(soptask.FieldOrganizationID, v)
- return u
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *SopTaskUpsert) UpdateOrganizationID() *SopTaskUpsert {
- u.SetExcluded(soptask.FieldOrganizationID)
- return u
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *SopTaskUpsert) AddOrganizationID(v uint64) *SopTaskUpsert {
- u.Add(soptask.FieldOrganizationID, v)
- return u
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (u *SopTaskUpsert) ClearOrganizationID() *SopTaskUpsert {
- u.SetNull(soptask.FieldOrganizationID)
- 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.SopTask.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(soptask.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *SopTaskUpsertOne) UpdateNewValues() *SopTaskUpsertOne {
- 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(soptask.FieldID)
- }
- if _, exists := u.create.mutation.CreatedAt(); exists {
- s.SetIgnore(soptask.FieldCreatedAt)
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.SopTask.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *SopTaskUpsertOne) Ignore() *SopTaskUpsertOne {
- 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 *SopTaskUpsertOne) DoNothing() *SopTaskUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the SopTaskCreate.OnConflict
- // documentation for more info.
- func (u *SopTaskUpsertOne) Update(set func(*SopTaskUpsert)) *SopTaskUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&SopTaskUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *SopTaskUpsertOne) SetUpdatedAt(v time.Time) *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *SopTaskUpsertOne) UpdateUpdatedAt() *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetStatus sets the "status" field.
- func (u *SopTaskUpsertOne) SetStatus(v uint8) *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.SetStatus(v)
- })
- }
- // AddStatus adds v to the "status" field.
- func (u *SopTaskUpsertOne) AddStatus(v uint8) *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.AddStatus(v)
- })
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *SopTaskUpsertOne) UpdateStatus() *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.UpdateStatus()
- })
- }
- // ClearStatus clears the value of the "status" field.
- func (u *SopTaskUpsertOne) ClearStatus() *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.ClearStatus()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *SopTaskUpsertOne) SetDeletedAt(v time.Time) *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *SopTaskUpsertOne) UpdateDeletedAt() *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *SopTaskUpsertOne) ClearDeletedAt() *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetName sets the "name" field.
- func (u *SopTaskUpsertOne) SetName(v string) *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.SetName(v)
- })
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *SopTaskUpsertOne) UpdateName() *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.UpdateName()
- })
- }
- // SetBotWxidList sets the "bot_wxid_list" field.
- func (u *SopTaskUpsertOne) SetBotWxidList(v []string) *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.SetBotWxidList(v)
- })
- }
- // UpdateBotWxidList sets the "bot_wxid_list" field to the value that was provided on create.
- func (u *SopTaskUpsertOne) UpdateBotWxidList() *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.UpdateBotWxidList()
- })
- }
- // ClearBotWxidList clears the value of the "bot_wxid_list" field.
- func (u *SopTaskUpsertOne) ClearBotWxidList() *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.ClearBotWxidList()
- })
- }
- // SetType sets the "type" field.
- func (u *SopTaskUpsertOne) SetType(v int) *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.SetType(v)
- })
- }
- // AddType adds v to the "type" field.
- func (u *SopTaskUpsertOne) AddType(v int) *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.AddType(v)
- })
- }
- // UpdateType sets the "type" field to the value that was provided on create.
- func (u *SopTaskUpsertOne) UpdateType() *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.UpdateType()
- })
- }
- // SetPlanStartTime sets the "plan_start_time" field.
- func (u *SopTaskUpsertOne) SetPlanStartTime(v time.Time) *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.SetPlanStartTime(v)
- })
- }
- // UpdatePlanStartTime sets the "plan_start_time" field to the value that was provided on create.
- func (u *SopTaskUpsertOne) UpdatePlanStartTime() *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.UpdatePlanStartTime()
- })
- }
- // ClearPlanStartTime clears the value of the "plan_start_time" field.
- func (u *SopTaskUpsertOne) ClearPlanStartTime() *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.ClearPlanStartTime()
- })
- }
- // SetPlanEndTime sets the "plan_end_time" field.
- func (u *SopTaskUpsertOne) SetPlanEndTime(v time.Time) *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.SetPlanEndTime(v)
- })
- }
- // UpdatePlanEndTime sets the "plan_end_time" field to the value that was provided on create.
- func (u *SopTaskUpsertOne) UpdatePlanEndTime() *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.UpdatePlanEndTime()
- })
- }
- // ClearPlanEndTime clears the value of the "plan_end_time" field.
- func (u *SopTaskUpsertOne) ClearPlanEndTime() *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.ClearPlanEndTime()
- })
- }
- // SetCreatorID sets the "creator_id" field.
- func (u *SopTaskUpsertOne) SetCreatorID(v string) *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.SetCreatorID(v)
- })
- }
- // UpdateCreatorID sets the "creator_id" field to the value that was provided on create.
- func (u *SopTaskUpsertOne) UpdateCreatorID() *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.UpdateCreatorID()
- })
- }
- // ClearCreatorID clears the value of the "creator_id" field.
- func (u *SopTaskUpsertOne) ClearCreatorID() *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.ClearCreatorID()
- })
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *SopTaskUpsertOne) SetOrganizationID(v uint64) *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.SetOrganizationID(v)
- })
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *SopTaskUpsertOne) AddOrganizationID(v uint64) *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.AddOrganizationID(v)
- })
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *SopTaskUpsertOne) UpdateOrganizationID() *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.UpdateOrganizationID()
- })
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (u *SopTaskUpsertOne) ClearOrganizationID() *SopTaskUpsertOne {
- return u.Update(func(s *SopTaskUpsert) {
- s.ClearOrganizationID()
- })
- }
- // Exec executes the query.
- func (u *SopTaskUpsertOne) Exec(ctx context.Context) error {
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for SopTaskCreate.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *SopTaskUpsertOne) 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 *SopTaskUpsertOne) 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 *SopTaskUpsertOne) IDX(ctx context.Context) uint64 {
- id, err := u.ID(ctx)
- if err != nil {
- panic(err)
- }
- return id
- }
- // SopTaskCreateBulk is the builder for creating many SopTask entities in bulk.
- type SopTaskCreateBulk struct {
- config
- err error
- builders []*SopTaskCreate
- conflict []sql.ConflictOption
- }
- // Save creates the SopTask entities in the database.
- func (stcb *SopTaskCreateBulk) Save(ctx context.Context) ([]*SopTask, error) {
- if stcb.err != nil {
- return nil, stcb.err
- }
- specs := make([]*sqlgraph.CreateSpec, len(stcb.builders))
- nodes := make([]*SopTask, len(stcb.builders))
- mutators := make([]Mutator, len(stcb.builders))
- for i := range stcb.builders {
- func(i int, root context.Context) {
- builder := stcb.builders[i]
- builder.defaults()
- var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
- mutation, ok := m.(*SopTaskMutation)
- 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, stcb.builders[i+1].mutation)
- } else {
- spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
- spec.OnConflict = stcb.conflict
- // Invoke the actual operation on the latest mutation in the chain.
- if err = sqlgraph.BatchCreate(ctx, stcb.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, stcb.builders[0].mutation); err != nil {
- return nil, err
- }
- }
- return nodes, nil
- }
- // SaveX is like Save, but panics if an error occurs.
- func (stcb *SopTaskCreateBulk) SaveX(ctx context.Context) []*SopTask {
- v, err := stcb.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (stcb *SopTaskCreateBulk) Exec(ctx context.Context) error {
- _, err := stcb.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (stcb *SopTaskCreateBulk) ExecX(ctx context.Context) {
- if err := stcb.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.SopTask.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.SopTaskUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (stcb *SopTaskCreateBulk) OnConflict(opts ...sql.ConflictOption) *SopTaskUpsertBulk {
- stcb.conflict = opts
- return &SopTaskUpsertBulk{
- create: stcb,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.SopTask.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (stcb *SopTaskCreateBulk) OnConflictColumns(columns ...string) *SopTaskUpsertBulk {
- stcb.conflict = append(stcb.conflict, sql.ConflictColumns(columns...))
- return &SopTaskUpsertBulk{
- create: stcb,
- }
- }
- // SopTaskUpsertBulk is the builder for "upsert"-ing
- // a bulk of SopTask nodes.
- type SopTaskUpsertBulk struct {
- create *SopTaskCreateBulk
- }
- // UpdateNewValues updates the mutable fields using the new values that
- // were set on create. Using this option is equivalent to using:
- //
- // client.SopTask.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(soptask.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *SopTaskUpsertBulk) UpdateNewValues() *SopTaskUpsertBulk {
- 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(soptask.FieldID)
- }
- if _, exists := b.mutation.CreatedAt(); exists {
- s.SetIgnore(soptask.FieldCreatedAt)
- }
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.SopTask.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *SopTaskUpsertBulk) Ignore() *SopTaskUpsertBulk {
- 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 *SopTaskUpsertBulk) DoNothing() *SopTaskUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the SopTaskCreateBulk.OnConflict
- // documentation for more info.
- func (u *SopTaskUpsertBulk) Update(set func(*SopTaskUpsert)) *SopTaskUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&SopTaskUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *SopTaskUpsertBulk) SetUpdatedAt(v time.Time) *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *SopTaskUpsertBulk) UpdateUpdatedAt() *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetStatus sets the "status" field.
- func (u *SopTaskUpsertBulk) SetStatus(v uint8) *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.SetStatus(v)
- })
- }
- // AddStatus adds v to the "status" field.
- func (u *SopTaskUpsertBulk) AddStatus(v uint8) *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.AddStatus(v)
- })
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *SopTaskUpsertBulk) UpdateStatus() *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.UpdateStatus()
- })
- }
- // ClearStatus clears the value of the "status" field.
- func (u *SopTaskUpsertBulk) ClearStatus() *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.ClearStatus()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *SopTaskUpsertBulk) SetDeletedAt(v time.Time) *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *SopTaskUpsertBulk) UpdateDeletedAt() *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *SopTaskUpsertBulk) ClearDeletedAt() *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetName sets the "name" field.
- func (u *SopTaskUpsertBulk) SetName(v string) *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.SetName(v)
- })
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *SopTaskUpsertBulk) UpdateName() *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.UpdateName()
- })
- }
- // SetBotWxidList sets the "bot_wxid_list" field.
- func (u *SopTaskUpsertBulk) SetBotWxidList(v []string) *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.SetBotWxidList(v)
- })
- }
- // UpdateBotWxidList sets the "bot_wxid_list" field to the value that was provided on create.
- func (u *SopTaskUpsertBulk) UpdateBotWxidList() *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.UpdateBotWxidList()
- })
- }
- // ClearBotWxidList clears the value of the "bot_wxid_list" field.
- func (u *SopTaskUpsertBulk) ClearBotWxidList() *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.ClearBotWxidList()
- })
- }
- // SetType sets the "type" field.
- func (u *SopTaskUpsertBulk) SetType(v int) *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.SetType(v)
- })
- }
- // AddType adds v to the "type" field.
- func (u *SopTaskUpsertBulk) AddType(v int) *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.AddType(v)
- })
- }
- // UpdateType sets the "type" field to the value that was provided on create.
- func (u *SopTaskUpsertBulk) UpdateType() *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.UpdateType()
- })
- }
- // SetPlanStartTime sets the "plan_start_time" field.
- func (u *SopTaskUpsertBulk) SetPlanStartTime(v time.Time) *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.SetPlanStartTime(v)
- })
- }
- // UpdatePlanStartTime sets the "plan_start_time" field to the value that was provided on create.
- func (u *SopTaskUpsertBulk) UpdatePlanStartTime() *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.UpdatePlanStartTime()
- })
- }
- // ClearPlanStartTime clears the value of the "plan_start_time" field.
- func (u *SopTaskUpsertBulk) ClearPlanStartTime() *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.ClearPlanStartTime()
- })
- }
- // SetPlanEndTime sets the "plan_end_time" field.
- func (u *SopTaskUpsertBulk) SetPlanEndTime(v time.Time) *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.SetPlanEndTime(v)
- })
- }
- // UpdatePlanEndTime sets the "plan_end_time" field to the value that was provided on create.
- func (u *SopTaskUpsertBulk) UpdatePlanEndTime() *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.UpdatePlanEndTime()
- })
- }
- // ClearPlanEndTime clears the value of the "plan_end_time" field.
- func (u *SopTaskUpsertBulk) ClearPlanEndTime() *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.ClearPlanEndTime()
- })
- }
- // SetCreatorID sets the "creator_id" field.
- func (u *SopTaskUpsertBulk) SetCreatorID(v string) *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.SetCreatorID(v)
- })
- }
- // UpdateCreatorID sets the "creator_id" field to the value that was provided on create.
- func (u *SopTaskUpsertBulk) UpdateCreatorID() *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.UpdateCreatorID()
- })
- }
- // ClearCreatorID clears the value of the "creator_id" field.
- func (u *SopTaskUpsertBulk) ClearCreatorID() *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.ClearCreatorID()
- })
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *SopTaskUpsertBulk) SetOrganizationID(v uint64) *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.SetOrganizationID(v)
- })
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *SopTaskUpsertBulk) AddOrganizationID(v uint64) *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.AddOrganizationID(v)
- })
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *SopTaskUpsertBulk) UpdateOrganizationID() *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.UpdateOrganizationID()
- })
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (u *SopTaskUpsertBulk) ClearOrganizationID() *SopTaskUpsertBulk {
- return u.Update(func(s *SopTaskUpsert) {
- s.ClearOrganizationID()
- })
- }
- // Exec executes the query.
- func (u *SopTaskUpsertBulk) 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 SopTaskCreateBulk instead", i)
- }
- }
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for SopTaskCreateBulk.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *SopTaskUpsertBulk) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
|