123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "wechat-api/ent/labeltagging"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- )
- // LabelTaggingCreate is the builder for creating a LabelTagging entity.
- type LabelTaggingCreate struct {
- config
- mutation *LabelTaggingMutation
- hooks []Hook
- conflict []sql.ConflictOption
- }
- // SetCreatedAt sets the "created_at" field.
- func (ltc *LabelTaggingCreate) SetCreatedAt(t time.Time) *LabelTaggingCreate {
- ltc.mutation.SetCreatedAt(t)
- return ltc
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (ltc *LabelTaggingCreate) SetNillableCreatedAt(t *time.Time) *LabelTaggingCreate {
- if t != nil {
- ltc.SetCreatedAt(*t)
- }
- return ltc
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (ltc *LabelTaggingCreate) SetUpdatedAt(t time.Time) *LabelTaggingCreate {
- ltc.mutation.SetUpdatedAt(t)
- return ltc
- }
- // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
- func (ltc *LabelTaggingCreate) SetNillableUpdatedAt(t *time.Time) *LabelTaggingCreate {
- if t != nil {
- ltc.SetUpdatedAt(*t)
- }
- return ltc
- }
- // SetStatus sets the "status" field.
- func (ltc *LabelTaggingCreate) SetStatus(u uint8) *LabelTaggingCreate {
- ltc.mutation.SetStatus(u)
- return ltc
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (ltc *LabelTaggingCreate) SetNillableStatus(u *uint8) *LabelTaggingCreate {
- if u != nil {
- ltc.SetStatus(*u)
- }
- return ltc
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (ltc *LabelTaggingCreate) SetDeletedAt(t time.Time) *LabelTaggingCreate {
- ltc.mutation.SetDeletedAt(t)
- return ltc
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (ltc *LabelTaggingCreate) SetNillableDeletedAt(t *time.Time) *LabelTaggingCreate {
- if t != nil {
- ltc.SetDeletedAt(*t)
- }
- return ltc
- }
- // SetOrganizationID sets the "organization_id" field.
- func (ltc *LabelTaggingCreate) SetOrganizationID(u uint64) *LabelTaggingCreate {
- ltc.mutation.SetOrganizationID(u)
- return ltc
- }
- // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
- func (ltc *LabelTaggingCreate) SetNillableOrganizationID(u *uint64) *LabelTaggingCreate {
- if u != nil {
- ltc.SetOrganizationID(*u)
- }
- return ltc
- }
- // SetType sets the "type" field.
- func (ltc *LabelTaggingCreate) SetType(i int) *LabelTaggingCreate {
- ltc.mutation.SetType(i)
- return ltc
- }
- // SetNillableType sets the "type" field if the given value is not nil.
- func (ltc *LabelTaggingCreate) SetNillableType(i *int) *LabelTaggingCreate {
- if i != nil {
- ltc.SetType(*i)
- }
- return ltc
- }
- // SetConditions sets the "conditions" field.
- func (ltc *LabelTaggingCreate) SetConditions(s string) *LabelTaggingCreate {
- ltc.mutation.SetConditions(s)
- return ltc
- }
- // SetNillableConditions sets the "conditions" field if the given value is not nil.
- func (ltc *LabelTaggingCreate) SetNillableConditions(s *string) *LabelTaggingCreate {
- if s != nil {
- ltc.SetConditions(*s)
- }
- return ltc
- }
- // SetActionLabelAdd sets the "action_label_add" field.
- func (ltc *LabelTaggingCreate) SetActionLabelAdd(u []uint64) *LabelTaggingCreate {
- ltc.mutation.SetActionLabelAdd(u)
- return ltc
- }
- // SetActionLabelDel sets the "action_label_del" field.
- func (ltc *LabelTaggingCreate) SetActionLabelDel(u []uint64) *LabelTaggingCreate {
- ltc.mutation.SetActionLabelDel(u)
- return ltc
- }
- // SetID sets the "id" field.
- func (ltc *LabelTaggingCreate) SetID(u uint64) *LabelTaggingCreate {
- ltc.mutation.SetID(u)
- return ltc
- }
- // Mutation returns the LabelTaggingMutation object of the builder.
- func (ltc *LabelTaggingCreate) Mutation() *LabelTaggingMutation {
- return ltc.mutation
- }
- // Save creates the LabelTagging in the database.
- func (ltc *LabelTaggingCreate) Save(ctx context.Context) (*LabelTagging, error) {
- if err := ltc.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, ltc.sqlSave, ltc.mutation, ltc.hooks)
- }
- // SaveX calls Save and panics if Save returns an error.
- func (ltc *LabelTaggingCreate) SaveX(ctx context.Context) *LabelTagging {
- v, err := ltc.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (ltc *LabelTaggingCreate) Exec(ctx context.Context) error {
- _, err := ltc.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (ltc *LabelTaggingCreate) ExecX(ctx context.Context) {
- if err := ltc.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (ltc *LabelTaggingCreate) defaults() error {
- if _, ok := ltc.mutation.CreatedAt(); !ok {
- if labeltagging.DefaultCreatedAt == nil {
- return fmt.Errorf("ent: uninitialized labeltagging.DefaultCreatedAt (forgotten import ent/runtime?)")
- }
- v := labeltagging.DefaultCreatedAt()
- ltc.mutation.SetCreatedAt(v)
- }
- if _, ok := ltc.mutation.UpdatedAt(); !ok {
- if labeltagging.DefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized labeltagging.DefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := labeltagging.DefaultUpdatedAt()
- ltc.mutation.SetUpdatedAt(v)
- }
- if _, ok := ltc.mutation.Status(); !ok {
- v := labeltagging.DefaultStatus
- ltc.mutation.SetStatus(v)
- }
- if _, ok := ltc.mutation.OrganizationID(); !ok {
- v := labeltagging.DefaultOrganizationID
- ltc.mutation.SetOrganizationID(v)
- }
- if _, ok := ltc.mutation.GetType(); !ok {
- v := labeltagging.DefaultType
- ltc.mutation.SetType(v)
- }
- if _, ok := ltc.mutation.Conditions(); !ok {
- v := labeltagging.DefaultConditions
- ltc.mutation.SetConditions(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (ltc *LabelTaggingCreate) check() error {
- if _, ok := ltc.mutation.CreatedAt(); !ok {
- return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "LabelTagging.created_at"`)}
- }
- if _, ok := ltc.mutation.UpdatedAt(); !ok {
- return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "LabelTagging.updated_at"`)}
- }
- if _, ok := ltc.mutation.OrganizationID(); !ok {
- return &ValidationError{Name: "organization_id", err: errors.New(`ent: missing required field "LabelTagging.organization_id"`)}
- }
- if _, ok := ltc.mutation.GetType(); !ok {
- return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "LabelTagging.type"`)}
- }
- if _, ok := ltc.mutation.Conditions(); !ok {
- return &ValidationError{Name: "conditions", err: errors.New(`ent: missing required field "LabelTagging.conditions"`)}
- }
- return nil
- }
- func (ltc *LabelTaggingCreate) sqlSave(ctx context.Context) (*LabelTagging, error) {
- if err := ltc.check(); err != nil {
- return nil, err
- }
- _node, _spec := ltc.createSpec()
- if err := sqlgraph.CreateNode(ctx, ltc.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)
- }
- ltc.mutation.id = &_node.ID
- ltc.mutation.done = true
- return _node, nil
- }
- func (ltc *LabelTaggingCreate) createSpec() (*LabelTagging, *sqlgraph.CreateSpec) {
- var (
- _node = &LabelTagging{config: ltc.config}
- _spec = sqlgraph.NewCreateSpec(labeltagging.Table, sqlgraph.NewFieldSpec(labeltagging.FieldID, field.TypeUint64))
- )
- _spec.OnConflict = ltc.conflict
- if id, ok := ltc.mutation.ID(); ok {
- _node.ID = id
- _spec.ID.Value = id
- }
- if value, ok := ltc.mutation.CreatedAt(); ok {
- _spec.SetField(labeltagging.FieldCreatedAt, field.TypeTime, value)
- _node.CreatedAt = value
- }
- if value, ok := ltc.mutation.UpdatedAt(); ok {
- _spec.SetField(labeltagging.FieldUpdatedAt, field.TypeTime, value)
- _node.UpdatedAt = value
- }
- if value, ok := ltc.mutation.Status(); ok {
- _spec.SetField(labeltagging.FieldStatus, field.TypeUint8, value)
- _node.Status = value
- }
- if value, ok := ltc.mutation.DeletedAt(); ok {
- _spec.SetField(labeltagging.FieldDeletedAt, field.TypeTime, value)
- _node.DeletedAt = value
- }
- if value, ok := ltc.mutation.OrganizationID(); ok {
- _spec.SetField(labeltagging.FieldOrganizationID, field.TypeUint64, value)
- _node.OrganizationID = value
- }
- if value, ok := ltc.mutation.GetType(); ok {
- _spec.SetField(labeltagging.FieldType, field.TypeInt, value)
- _node.Type = value
- }
- if value, ok := ltc.mutation.Conditions(); ok {
- _spec.SetField(labeltagging.FieldConditions, field.TypeString, value)
- _node.Conditions = value
- }
- if value, ok := ltc.mutation.ActionLabelAdd(); ok {
- _spec.SetField(labeltagging.FieldActionLabelAdd, field.TypeJSON, value)
- _node.ActionLabelAdd = value
- }
- if value, ok := ltc.mutation.ActionLabelDel(); ok {
- _spec.SetField(labeltagging.FieldActionLabelDel, field.TypeJSON, value)
- _node.ActionLabelDel = value
- }
- return _node, _spec
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.LabelTagging.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.LabelTaggingUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (ltc *LabelTaggingCreate) OnConflict(opts ...sql.ConflictOption) *LabelTaggingUpsertOne {
- ltc.conflict = opts
- return &LabelTaggingUpsertOne{
- create: ltc,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.LabelTagging.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (ltc *LabelTaggingCreate) OnConflictColumns(columns ...string) *LabelTaggingUpsertOne {
- ltc.conflict = append(ltc.conflict, sql.ConflictColumns(columns...))
- return &LabelTaggingUpsertOne{
- create: ltc,
- }
- }
- type (
- // LabelTaggingUpsertOne is the builder for "upsert"-ing
- // one LabelTagging node.
- LabelTaggingUpsertOne struct {
- create *LabelTaggingCreate
- }
- // LabelTaggingUpsert is the "OnConflict" setter.
- LabelTaggingUpsert struct {
- *sql.UpdateSet
- }
- )
- // SetUpdatedAt sets the "updated_at" field.
- func (u *LabelTaggingUpsert) SetUpdatedAt(v time.Time) *LabelTaggingUpsert {
- u.Set(labeltagging.FieldUpdatedAt, v)
- return u
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *LabelTaggingUpsert) UpdateUpdatedAt() *LabelTaggingUpsert {
- u.SetExcluded(labeltagging.FieldUpdatedAt)
- return u
- }
- // SetStatus sets the "status" field.
- func (u *LabelTaggingUpsert) SetStatus(v uint8) *LabelTaggingUpsert {
- u.Set(labeltagging.FieldStatus, v)
- return u
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *LabelTaggingUpsert) UpdateStatus() *LabelTaggingUpsert {
- u.SetExcluded(labeltagging.FieldStatus)
- return u
- }
- // AddStatus adds v to the "status" field.
- func (u *LabelTaggingUpsert) AddStatus(v uint8) *LabelTaggingUpsert {
- u.Add(labeltagging.FieldStatus, v)
- return u
- }
- // ClearStatus clears the value of the "status" field.
- func (u *LabelTaggingUpsert) ClearStatus() *LabelTaggingUpsert {
- u.SetNull(labeltagging.FieldStatus)
- return u
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *LabelTaggingUpsert) SetDeletedAt(v time.Time) *LabelTaggingUpsert {
- u.Set(labeltagging.FieldDeletedAt, v)
- return u
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *LabelTaggingUpsert) UpdateDeletedAt() *LabelTaggingUpsert {
- u.SetExcluded(labeltagging.FieldDeletedAt)
- return u
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *LabelTaggingUpsert) ClearDeletedAt() *LabelTaggingUpsert {
- u.SetNull(labeltagging.FieldDeletedAt)
- return u
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *LabelTaggingUpsert) SetOrganizationID(v uint64) *LabelTaggingUpsert {
- u.Set(labeltagging.FieldOrganizationID, v)
- return u
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *LabelTaggingUpsert) UpdateOrganizationID() *LabelTaggingUpsert {
- u.SetExcluded(labeltagging.FieldOrganizationID)
- return u
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *LabelTaggingUpsert) AddOrganizationID(v uint64) *LabelTaggingUpsert {
- u.Add(labeltagging.FieldOrganizationID, v)
- return u
- }
- // SetType sets the "type" field.
- func (u *LabelTaggingUpsert) SetType(v int) *LabelTaggingUpsert {
- u.Set(labeltagging.FieldType, v)
- return u
- }
- // UpdateType sets the "type" field to the value that was provided on create.
- func (u *LabelTaggingUpsert) UpdateType() *LabelTaggingUpsert {
- u.SetExcluded(labeltagging.FieldType)
- return u
- }
- // AddType adds v to the "type" field.
- func (u *LabelTaggingUpsert) AddType(v int) *LabelTaggingUpsert {
- u.Add(labeltagging.FieldType, v)
- return u
- }
- // SetConditions sets the "conditions" field.
- func (u *LabelTaggingUpsert) SetConditions(v string) *LabelTaggingUpsert {
- u.Set(labeltagging.FieldConditions, v)
- return u
- }
- // UpdateConditions sets the "conditions" field to the value that was provided on create.
- func (u *LabelTaggingUpsert) UpdateConditions() *LabelTaggingUpsert {
- u.SetExcluded(labeltagging.FieldConditions)
- return u
- }
- // SetActionLabelAdd sets the "action_label_add" field.
- func (u *LabelTaggingUpsert) SetActionLabelAdd(v []uint64) *LabelTaggingUpsert {
- u.Set(labeltagging.FieldActionLabelAdd, v)
- return u
- }
- // UpdateActionLabelAdd sets the "action_label_add" field to the value that was provided on create.
- func (u *LabelTaggingUpsert) UpdateActionLabelAdd() *LabelTaggingUpsert {
- u.SetExcluded(labeltagging.FieldActionLabelAdd)
- return u
- }
- // ClearActionLabelAdd clears the value of the "action_label_add" field.
- func (u *LabelTaggingUpsert) ClearActionLabelAdd() *LabelTaggingUpsert {
- u.SetNull(labeltagging.FieldActionLabelAdd)
- return u
- }
- // SetActionLabelDel sets the "action_label_del" field.
- func (u *LabelTaggingUpsert) SetActionLabelDel(v []uint64) *LabelTaggingUpsert {
- u.Set(labeltagging.FieldActionLabelDel, v)
- return u
- }
- // UpdateActionLabelDel sets the "action_label_del" field to the value that was provided on create.
- func (u *LabelTaggingUpsert) UpdateActionLabelDel() *LabelTaggingUpsert {
- u.SetExcluded(labeltagging.FieldActionLabelDel)
- return u
- }
- // ClearActionLabelDel clears the value of the "action_label_del" field.
- func (u *LabelTaggingUpsert) ClearActionLabelDel() *LabelTaggingUpsert {
- u.SetNull(labeltagging.FieldActionLabelDel)
- 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.LabelTagging.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(labeltagging.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *LabelTaggingUpsertOne) UpdateNewValues() *LabelTaggingUpsertOne {
- 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(labeltagging.FieldID)
- }
- if _, exists := u.create.mutation.CreatedAt(); exists {
- s.SetIgnore(labeltagging.FieldCreatedAt)
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.LabelTagging.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *LabelTaggingUpsertOne) Ignore() *LabelTaggingUpsertOne {
- 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 *LabelTaggingUpsertOne) DoNothing() *LabelTaggingUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the LabelTaggingCreate.OnConflict
- // documentation for more info.
- func (u *LabelTaggingUpsertOne) Update(set func(*LabelTaggingUpsert)) *LabelTaggingUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&LabelTaggingUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *LabelTaggingUpsertOne) SetUpdatedAt(v time.Time) *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *LabelTaggingUpsertOne) UpdateUpdatedAt() *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetStatus sets the "status" field.
- func (u *LabelTaggingUpsertOne) SetStatus(v uint8) *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.SetStatus(v)
- })
- }
- // AddStatus adds v to the "status" field.
- func (u *LabelTaggingUpsertOne) AddStatus(v uint8) *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.AddStatus(v)
- })
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *LabelTaggingUpsertOne) UpdateStatus() *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.UpdateStatus()
- })
- }
- // ClearStatus clears the value of the "status" field.
- func (u *LabelTaggingUpsertOne) ClearStatus() *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.ClearStatus()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *LabelTaggingUpsertOne) SetDeletedAt(v time.Time) *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *LabelTaggingUpsertOne) UpdateDeletedAt() *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *LabelTaggingUpsertOne) ClearDeletedAt() *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *LabelTaggingUpsertOne) SetOrganizationID(v uint64) *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.SetOrganizationID(v)
- })
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *LabelTaggingUpsertOne) AddOrganizationID(v uint64) *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.AddOrganizationID(v)
- })
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *LabelTaggingUpsertOne) UpdateOrganizationID() *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.UpdateOrganizationID()
- })
- }
- // SetType sets the "type" field.
- func (u *LabelTaggingUpsertOne) SetType(v int) *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.SetType(v)
- })
- }
- // AddType adds v to the "type" field.
- func (u *LabelTaggingUpsertOne) AddType(v int) *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.AddType(v)
- })
- }
- // UpdateType sets the "type" field to the value that was provided on create.
- func (u *LabelTaggingUpsertOne) UpdateType() *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.UpdateType()
- })
- }
- // SetConditions sets the "conditions" field.
- func (u *LabelTaggingUpsertOne) SetConditions(v string) *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.SetConditions(v)
- })
- }
- // UpdateConditions sets the "conditions" field to the value that was provided on create.
- func (u *LabelTaggingUpsertOne) UpdateConditions() *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.UpdateConditions()
- })
- }
- // SetActionLabelAdd sets the "action_label_add" field.
- func (u *LabelTaggingUpsertOne) SetActionLabelAdd(v []uint64) *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.SetActionLabelAdd(v)
- })
- }
- // UpdateActionLabelAdd sets the "action_label_add" field to the value that was provided on create.
- func (u *LabelTaggingUpsertOne) UpdateActionLabelAdd() *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.UpdateActionLabelAdd()
- })
- }
- // ClearActionLabelAdd clears the value of the "action_label_add" field.
- func (u *LabelTaggingUpsertOne) ClearActionLabelAdd() *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.ClearActionLabelAdd()
- })
- }
- // SetActionLabelDel sets the "action_label_del" field.
- func (u *LabelTaggingUpsertOne) SetActionLabelDel(v []uint64) *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.SetActionLabelDel(v)
- })
- }
- // UpdateActionLabelDel sets the "action_label_del" field to the value that was provided on create.
- func (u *LabelTaggingUpsertOne) UpdateActionLabelDel() *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.UpdateActionLabelDel()
- })
- }
- // ClearActionLabelDel clears the value of the "action_label_del" field.
- func (u *LabelTaggingUpsertOne) ClearActionLabelDel() *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.ClearActionLabelDel()
- })
- }
- // Exec executes the query.
- func (u *LabelTaggingUpsertOne) Exec(ctx context.Context) error {
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for LabelTaggingCreate.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *LabelTaggingUpsertOne) 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 *LabelTaggingUpsertOne) 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 *LabelTaggingUpsertOne) IDX(ctx context.Context) uint64 {
- id, err := u.ID(ctx)
- if err != nil {
- panic(err)
- }
- return id
- }
- // LabelTaggingCreateBulk is the builder for creating many LabelTagging entities in bulk.
- type LabelTaggingCreateBulk struct {
- config
- err error
- builders []*LabelTaggingCreate
- conflict []sql.ConflictOption
- }
- // Save creates the LabelTagging entities in the database.
- func (ltcb *LabelTaggingCreateBulk) Save(ctx context.Context) ([]*LabelTagging, error) {
- if ltcb.err != nil {
- return nil, ltcb.err
- }
- specs := make([]*sqlgraph.CreateSpec, len(ltcb.builders))
- nodes := make([]*LabelTagging, len(ltcb.builders))
- mutators := make([]Mutator, len(ltcb.builders))
- for i := range ltcb.builders {
- func(i int, root context.Context) {
- builder := ltcb.builders[i]
- builder.defaults()
- var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
- mutation, ok := m.(*LabelTaggingMutation)
- 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, ltcb.builders[i+1].mutation)
- } else {
- spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
- spec.OnConflict = ltcb.conflict
- // Invoke the actual operation on the latest mutation in the chain.
- if err = sqlgraph.BatchCreate(ctx, ltcb.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, ltcb.builders[0].mutation); err != nil {
- return nil, err
- }
- }
- return nodes, nil
- }
- // SaveX is like Save, but panics if an error occurs.
- func (ltcb *LabelTaggingCreateBulk) SaveX(ctx context.Context) []*LabelTagging {
- v, err := ltcb.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (ltcb *LabelTaggingCreateBulk) Exec(ctx context.Context) error {
- _, err := ltcb.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (ltcb *LabelTaggingCreateBulk) ExecX(ctx context.Context) {
- if err := ltcb.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.LabelTagging.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.LabelTaggingUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (ltcb *LabelTaggingCreateBulk) OnConflict(opts ...sql.ConflictOption) *LabelTaggingUpsertBulk {
- ltcb.conflict = opts
- return &LabelTaggingUpsertBulk{
- create: ltcb,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.LabelTagging.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (ltcb *LabelTaggingCreateBulk) OnConflictColumns(columns ...string) *LabelTaggingUpsertBulk {
- ltcb.conflict = append(ltcb.conflict, sql.ConflictColumns(columns...))
- return &LabelTaggingUpsertBulk{
- create: ltcb,
- }
- }
- // LabelTaggingUpsertBulk is the builder for "upsert"-ing
- // a bulk of LabelTagging nodes.
- type LabelTaggingUpsertBulk struct {
- create *LabelTaggingCreateBulk
- }
- // UpdateNewValues updates the mutable fields using the new values that
- // were set on create. Using this option is equivalent to using:
- //
- // client.LabelTagging.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(labeltagging.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *LabelTaggingUpsertBulk) UpdateNewValues() *LabelTaggingUpsertBulk {
- 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(labeltagging.FieldID)
- }
- if _, exists := b.mutation.CreatedAt(); exists {
- s.SetIgnore(labeltagging.FieldCreatedAt)
- }
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.LabelTagging.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *LabelTaggingUpsertBulk) Ignore() *LabelTaggingUpsertBulk {
- 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 *LabelTaggingUpsertBulk) DoNothing() *LabelTaggingUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the LabelTaggingCreateBulk.OnConflict
- // documentation for more info.
- func (u *LabelTaggingUpsertBulk) Update(set func(*LabelTaggingUpsert)) *LabelTaggingUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&LabelTaggingUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *LabelTaggingUpsertBulk) SetUpdatedAt(v time.Time) *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *LabelTaggingUpsertBulk) UpdateUpdatedAt() *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetStatus sets the "status" field.
- func (u *LabelTaggingUpsertBulk) SetStatus(v uint8) *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.SetStatus(v)
- })
- }
- // AddStatus adds v to the "status" field.
- func (u *LabelTaggingUpsertBulk) AddStatus(v uint8) *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.AddStatus(v)
- })
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *LabelTaggingUpsertBulk) UpdateStatus() *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.UpdateStatus()
- })
- }
- // ClearStatus clears the value of the "status" field.
- func (u *LabelTaggingUpsertBulk) ClearStatus() *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.ClearStatus()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *LabelTaggingUpsertBulk) SetDeletedAt(v time.Time) *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *LabelTaggingUpsertBulk) UpdateDeletedAt() *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *LabelTaggingUpsertBulk) ClearDeletedAt() *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *LabelTaggingUpsertBulk) SetOrganizationID(v uint64) *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.SetOrganizationID(v)
- })
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *LabelTaggingUpsertBulk) AddOrganizationID(v uint64) *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.AddOrganizationID(v)
- })
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *LabelTaggingUpsertBulk) UpdateOrganizationID() *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.UpdateOrganizationID()
- })
- }
- // SetType sets the "type" field.
- func (u *LabelTaggingUpsertBulk) SetType(v int) *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.SetType(v)
- })
- }
- // AddType adds v to the "type" field.
- func (u *LabelTaggingUpsertBulk) AddType(v int) *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.AddType(v)
- })
- }
- // UpdateType sets the "type" field to the value that was provided on create.
- func (u *LabelTaggingUpsertBulk) UpdateType() *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.UpdateType()
- })
- }
- // SetConditions sets the "conditions" field.
- func (u *LabelTaggingUpsertBulk) SetConditions(v string) *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.SetConditions(v)
- })
- }
- // UpdateConditions sets the "conditions" field to the value that was provided on create.
- func (u *LabelTaggingUpsertBulk) UpdateConditions() *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.UpdateConditions()
- })
- }
- // SetActionLabelAdd sets the "action_label_add" field.
- func (u *LabelTaggingUpsertBulk) SetActionLabelAdd(v []uint64) *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.SetActionLabelAdd(v)
- })
- }
- // UpdateActionLabelAdd sets the "action_label_add" field to the value that was provided on create.
- func (u *LabelTaggingUpsertBulk) UpdateActionLabelAdd() *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.UpdateActionLabelAdd()
- })
- }
- // ClearActionLabelAdd clears the value of the "action_label_add" field.
- func (u *LabelTaggingUpsertBulk) ClearActionLabelAdd() *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.ClearActionLabelAdd()
- })
- }
- // SetActionLabelDel sets the "action_label_del" field.
- func (u *LabelTaggingUpsertBulk) SetActionLabelDel(v []uint64) *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.SetActionLabelDel(v)
- })
- }
- // UpdateActionLabelDel sets the "action_label_del" field to the value that was provided on create.
- func (u *LabelTaggingUpsertBulk) UpdateActionLabelDel() *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.UpdateActionLabelDel()
- })
- }
- // ClearActionLabelDel clears the value of the "action_label_del" field.
- func (u *LabelTaggingUpsertBulk) ClearActionLabelDel() *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.ClearActionLabelDel()
- })
- }
- // Exec executes the query.
- func (u *LabelTaggingUpsertBulk) 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 LabelTaggingCreateBulk instead", i)
- }
- }
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for LabelTaggingCreateBulk.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *LabelTaggingUpsertBulk) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
|