1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120 |
- // 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
- }
- // 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)
- }
- 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.GetType(); !ok {
- return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "LabelTagging.type"`)}
- }
- 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.TypeJSON, 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
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (u *LabelTaggingUpsert) ClearOrganizationID() *LabelTaggingUpsert {
- u.SetNull(labeltagging.FieldOrganizationID)
- 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
- }
- // ClearConditions clears the value of the "conditions" field.
- func (u *LabelTaggingUpsert) ClearConditions() *LabelTaggingUpsert {
- u.SetNull(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()
- })
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (u *LabelTaggingUpsertOne) ClearOrganizationID() *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.ClearOrganizationID()
- })
- }
- // 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()
- })
- }
- // ClearConditions clears the value of the "conditions" field.
- func (u *LabelTaggingUpsertOne) ClearConditions() *LabelTaggingUpsertOne {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.ClearConditions()
- })
- }
- // 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()
- })
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (u *LabelTaggingUpsertBulk) ClearOrganizationID() *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.ClearOrganizationID()
- })
- }
- // 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()
- })
- }
- // ClearConditions clears the value of the "conditions" field.
- func (u *LabelTaggingUpsertBulk) ClearConditions() *LabelTaggingUpsertBulk {
- return u.Update(func(s *LabelTaggingUpsert) {
- s.ClearConditions()
- })
- }
- // 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)
- }
- }
|