1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "wechat-api/ent/contact"
- "wechat-api/ent/labelrelationship"
- "wechat-api/ent/messagerecords"
- "wechat-api/ent/predicate"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- )
- // ContactUpdate is the builder for updating Contact entities.
- type ContactUpdate struct {
- config
- hooks []Hook
- mutation *ContactMutation
- }
- // Where appends a list predicates to the ContactUpdate builder.
- func (cu *ContactUpdate) Where(ps ...predicate.Contact) *ContactUpdate {
- cu.mutation.Where(ps...)
- return cu
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (cu *ContactUpdate) SetUpdatedAt(t time.Time) *ContactUpdate {
- cu.mutation.SetUpdatedAt(t)
- return cu
- }
- // SetStatus sets the "status" field.
- func (cu *ContactUpdate) SetStatus(u uint8) *ContactUpdate {
- cu.mutation.ResetStatus()
- cu.mutation.SetStatus(u)
- return cu
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableStatus(u *uint8) *ContactUpdate {
- if u != nil {
- cu.SetStatus(*u)
- }
- return cu
- }
- // AddStatus adds u to the "status" field.
- func (cu *ContactUpdate) AddStatus(u int8) *ContactUpdate {
- cu.mutation.AddStatus(u)
- return cu
- }
- // ClearStatus clears the value of the "status" field.
- func (cu *ContactUpdate) ClearStatus() *ContactUpdate {
- cu.mutation.ClearStatus()
- return cu
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (cu *ContactUpdate) SetDeletedAt(t time.Time) *ContactUpdate {
- cu.mutation.SetDeletedAt(t)
- return cu
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableDeletedAt(t *time.Time) *ContactUpdate {
- if t != nil {
- cu.SetDeletedAt(*t)
- }
- return cu
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (cu *ContactUpdate) ClearDeletedAt() *ContactUpdate {
- cu.mutation.ClearDeletedAt()
- return cu
- }
- // SetWxWxid sets the "wx_wxid" field.
- func (cu *ContactUpdate) SetWxWxid(s string) *ContactUpdate {
- cu.mutation.SetWxWxid(s)
- return cu
- }
- // SetNillableWxWxid sets the "wx_wxid" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableWxWxid(s *string) *ContactUpdate {
- if s != nil {
- cu.SetWxWxid(*s)
- }
- return cu
- }
- // SetType sets the "type" field.
- func (cu *ContactUpdate) SetType(i int) *ContactUpdate {
- cu.mutation.ResetType()
- cu.mutation.SetType(i)
- return cu
- }
- // SetNillableType sets the "type" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableType(i *int) *ContactUpdate {
- if i != nil {
- cu.SetType(*i)
- }
- return cu
- }
- // AddType adds i to the "type" field.
- func (cu *ContactUpdate) AddType(i int) *ContactUpdate {
- cu.mutation.AddType(i)
- return cu
- }
- // ClearType clears the value of the "type" field.
- func (cu *ContactUpdate) ClearType() *ContactUpdate {
- cu.mutation.ClearType()
- return cu
- }
- // SetWxid sets the "wxid" field.
- func (cu *ContactUpdate) SetWxid(s string) *ContactUpdate {
- cu.mutation.SetWxid(s)
- return cu
- }
- // SetNillableWxid sets the "wxid" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableWxid(s *string) *ContactUpdate {
- if s != nil {
- cu.SetWxid(*s)
- }
- return cu
- }
- // SetAccount sets the "account" field.
- func (cu *ContactUpdate) SetAccount(s string) *ContactUpdate {
- cu.mutation.SetAccount(s)
- return cu
- }
- // SetNillableAccount sets the "account" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableAccount(s *string) *ContactUpdate {
- if s != nil {
- cu.SetAccount(*s)
- }
- return cu
- }
- // SetNickname sets the "nickname" field.
- func (cu *ContactUpdate) SetNickname(s string) *ContactUpdate {
- cu.mutation.SetNickname(s)
- return cu
- }
- // SetNillableNickname sets the "nickname" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableNickname(s *string) *ContactUpdate {
- if s != nil {
- cu.SetNickname(*s)
- }
- return cu
- }
- // SetMarkname sets the "markname" field.
- func (cu *ContactUpdate) SetMarkname(s string) *ContactUpdate {
- cu.mutation.SetMarkname(s)
- return cu
- }
- // SetNillableMarkname sets the "markname" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableMarkname(s *string) *ContactUpdate {
- if s != nil {
- cu.SetMarkname(*s)
- }
- return cu
- }
- // SetHeadimg sets the "headimg" field.
- func (cu *ContactUpdate) SetHeadimg(s string) *ContactUpdate {
- cu.mutation.SetHeadimg(s)
- return cu
- }
- // SetNillableHeadimg sets the "headimg" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableHeadimg(s *string) *ContactUpdate {
- if s != nil {
- cu.SetHeadimg(*s)
- }
- return cu
- }
- // SetSex sets the "sex" field.
- func (cu *ContactUpdate) SetSex(i int) *ContactUpdate {
- cu.mutation.ResetSex()
- cu.mutation.SetSex(i)
- return cu
- }
- // SetNillableSex sets the "sex" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableSex(i *int) *ContactUpdate {
- if i != nil {
- cu.SetSex(*i)
- }
- return cu
- }
- // AddSex adds i to the "sex" field.
- func (cu *ContactUpdate) AddSex(i int) *ContactUpdate {
- cu.mutation.AddSex(i)
- return cu
- }
- // SetStarrole sets the "starrole" field.
- func (cu *ContactUpdate) SetStarrole(s string) *ContactUpdate {
- cu.mutation.SetStarrole(s)
- return cu
- }
- // SetNillableStarrole sets the "starrole" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableStarrole(s *string) *ContactUpdate {
- if s != nil {
- cu.SetStarrole(*s)
- }
- return cu
- }
- // SetDontseeit sets the "dontseeit" field.
- func (cu *ContactUpdate) SetDontseeit(i int) *ContactUpdate {
- cu.mutation.ResetDontseeit()
- cu.mutation.SetDontseeit(i)
- return cu
- }
- // SetNillableDontseeit sets the "dontseeit" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableDontseeit(i *int) *ContactUpdate {
- if i != nil {
- cu.SetDontseeit(*i)
- }
- return cu
- }
- // AddDontseeit adds i to the "dontseeit" field.
- func (cu *ContactUpdate) AddDontseeit(i int) *ContactUpdate {
- cu.mutation.AddDontseeit(i)
- return cu
- }
- // SetDontseeme sets the "dontseeme" field.
- func (cu *ContactUpdate) SetDontseeme(i int) *ContactUpdate {
- cu.mutation.ResetDontseeme()
- cu.mutation.SetDontseeme(i)
- return cu
- }
- // SetNillableDontseeme sets the "dontseeme" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableDontseeme(i *int) *ContactUpdate {
- if i != nil {
- cu.SetDontseeme(*i)
- }
- return cu
- }
- // AddDontseeme adds i to the "dontseeme" field.
- func (cu *ContactUpdate) AddDontseeme(i int) *ContactUpdate {
- cu.mutation.AddDontseeme(i)
- return cu
- }
- // SetLag sets the "lag" field.
- func (cu *ContactUpdate) SetLag(s string) *ContactUpdate {
- cu.mutation.SetLag(s)
- return cu
- }
- // SetNillableLag sets the "lag" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableLag(s *string) *ContactUpdate {
- if s != nil {
- cu.SetLag(*s)
- }
- return cu
- }
- // SetGid sets the "gid" field.
- func (cu *ContactUpdate) SetGid(s string) *ContactUpdate {
- cu.mutation.SetGid(s)
- return cu
- }
- // SetNillableGid sets the "gid" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableGid(s *string) *ContactUpdate {
- if s != nil {
- cu.SetGid(*s)
- }
- return cu
- }
- // SetGname sets the "gname" field.
- func (cu *ContactUpdate) SetGname(s string) *ContactUpdate {
- cu.mutation.SetGname(s)
- return cu
- }
- // SetNillableGname sets the "gname" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableGname(s *string) *ContactUpdate {
- if s != nil {
- cu.SetGname(*s)
- }
- return cu
- }
- // SetV3 sets the "v3" field.
- func (cu *ContactUpdate) SetV3(s string) *ContactUpdate {
- cu.mutation.SetV3(s)
- return cu
- }
- // SetNillableV3 sets the "v3" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableV3(s *string) *ContactUpdate {
- if s != nil {
- cu.SetV3(*s)
- }
- return cu
- }
- // SetOrganizationID sets the "organization_id" field.
- func (cu *ContactUpdate) SetOrganizationID(u uint64) *ContactUpdate {
- cu.mutation.ResetOrganizationID()
- cu.mutation.SetOrganizationID(u)
- return cu
- }
- // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableOrganizationID(u *uint64) *ContactUpdate {
- if u != nil {
- cu.SetOrganizationID(*u)
- }
- return cu
- }
- // AddOrganizationID adds u to the "organization_id" field.
- func (cu *ContactUpdate) AddOrganizationID(u int64) *ContactUpdate {
- cu.mutation.AddOrganizationID(u)
- return cu
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (cu *ContactUpdate) ClearOrganizationID() *ContactUpdate {
- cu.mutation.ClearOrganizationID()
- return cu
- }
- // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by IDs.
- func (cu *ContactUpdate) AddContactRelationshipIDs(ids ...uint64) *ContactUpdate {
- cu.mutation.AddContactRelationshipIDs(ids...)
- return cu
- }
- // AddContactRelationships adds the "contact_relationships" edges to the LabelRelationship entity.
- func (cu *ContactUpdate) AddContactRelationships(l ...*LabelRelationship) *ContactUpdate {
- ids := make([]uint64, len(l))
- for i := range l {
- ids[i] = l[i].ID
- }
- return cu.AddContactRelationshipIDs(ids...)
- }
- // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by IDs.
- func (cu *ContactUpdate) AddContactMessageIDs(ids ...uint64) *ContactUpdate {
- cu.mutation.AddContactMessageIDs(ids...)
- return cu
- }
- // AddContactMessages adds the "contact_messages" edges to the MessageRecords entity.
- func (cu *ContactUpdate) AddContactMessages(m ...*MessageRecords) *ContactUpdate {
- ids := make([]uint64, len(m))
- for i := range m {
- ids[i] = m[i].ID
- }
- return cu.AddContactMessageIDs(ids...)
- }
- // Mutation returns the ContactMutation object of the builder.
- func (cu *ContactUpdate) Mutation() *ContactMutation {
- return cu.mutation
- }
- // ClearContactRelationships clears all "contact_relationships" edges to the LabelRelationship entity.
- func (cu *ContactUpdate) ClearContactRelationships() *ContactUpdate {
- cu.mutation.ClearContactRelationships()
- return cu
- }
- // RemoveContactRelationshipIDs removes the "contact_relationships" edge to LabelRelationship entities by IDs.
- func (cu *ContactUpdate) RemoveContactRelationshipIDs(ids ...uint64) *ContactUpdate {
- cu.mutation.RemoveContactRelationshipIDs(ids...)
- return cu
- }
- // RemoveContactRelationships removes "contact_relationships" edges to LabelRelationship entities.
- func (cu *ContactUpdate) RemoveContactRelationships(l ...*LabelRelationship) *ContactUpdate {
- ids := make([]uint64, len(l))
- for i := range l {
- ids[i] = l[i].ID
- }
- return cu.RemoveContactRelationshipIDs(ids...)
- }
- // ClearContactMessages clears all "contact_messages" edges to the MessageRecords entity.
- func (cu *ContactUpdate) ClearContactMessages() *ContactUpdate {
- cu.mutation.ClearContactMessages()
- return cu
- }
- // RemoveContactMessageIDs removes the "contact_messages" edge to MessageRecords entities by IDs.
- func (cu *ContactUpdate) RemoveContactMessageIDs(ids ...uint64) *ContactUpdate {
- cu.mutation.RemoveContactMessageIDs(ids...)
- return cu
- }
- // RemoveContactMessages removes "contact_messages" edges to MessageRecords entities.
- func (cu *ContactUpdate) RemoveContactMessages(m ...*MessageRecords) *ContactUpdate {
- ids := make([]uint64, len(m))
- for i := range m {
- ids[i] = m[i].ID
- }
- return cu.RemoveContactMessageIDs(ids...)
- }
- // Save executes the query and returns the number of nodes affected by the update operation.
- func (cu *ContactUpdate) Save(ctx context.Context) (int, error) {
- if err := cu.defaults(); err != nil {
- return 0, err
- }
- return withHooks(ctx, cu.sqlSave, cu.mutation, cu.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (cu *ContactUpdate) SaveX(ctx context.Context) int {
- affected, err := cu.Save(ctx)
- if err != nil {
- panic(err)
- }
- return affected
- }
- // Exec executes the query.
- func (cu *ContactUpdate) Exec(ctx context.Context) error {
- _, err := cu.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (cu *ContactUpdate) ExecX(ctx context.Context) {
- if err := cu.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (cu *ContactUpdate) defaults() error {
- if _, ok := cu.mutation.UpdatedAt(); !ok {
- if contact.UpdateDefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized contact.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := contact.UpdateDefaultUpdatedAt()
- cu.mutation.SetUpdatedAt(v)
- }
- return nil
- }
- func (cu *ContactUpdate) sqlSave(ctx context.Context) (n int, err error) {
- _spec := sqlgraph.NewUpdateSpec(contact.Table, contact.Columns, sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64))
- if ps := cu.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := cu.mutation.UpdatedAt(); ok {
- _spec.SetField(contact.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := cu.mutation.Status(); ok {
- _spec.SetField(contact.FieldStatus, field.TypeUint8, value)
- }
- if value, ok := cu.mutation.AddedStatus(); ok {
- _spec.AddField(contact.FieldStatus, field.TypeUint8, value)
- }
- if cu.mutation.StatusCleared() {
- _spec.ClearField(contact.FieldStatus, field.TypeUint8)
- }
- if value, ok := cu.mutation.DeletedAt(); ok {
- _spec.SetField(contact.FieldDeletedAt, field.TypeTime, value)
- }
- if cu.mutation.DeletedAtCleared() {
- _spec.ClearField(contact.FieldDeletedAt, field.TypeTime)
- }
- if value, ok := cu.mutation.WxWxid(); ok {
- _spec.SetField(contact.FieldWxWxid, field.TypeString, value)
- }
- if value, ok := cu.mutation.GetType(); ok {
- _spec.SetField(contact.FieldType, field.TypeInt, value)
- }
- if value, ok := cu.mutation.AddedType(); ok {
- _spec.AddField(contact.FieldType, field.TypeInt, value)
- }
- if cu.mutation.TypeCleared() {
- _spec.ClearField(contact.FieldType, field.TypeInt)
- }
- if value, ok := cu.mutation.Wxid(); ok {
- _spec.SetField(contact.FieldWxid, field.TypeString, value)
- }
- if value, ok := cu.mutation.Account(); ok {
- _spec.SetField(contact.FieldAccount, field.TypeString, value)
- }
- if value, ok := cu.mutation.Nickname(); ok {
- _spec.SetField(contact.FieldNickname, field.TypeString, value)
- }
- if value, ok := cu.mutation.Markname(); ok {
- _spec.SetField(contact.FieldMarkname, field.TypeString, value)
- }
- if value, ok := cu.mutation.Headimg(); ok {
- _spec.SetField(contact.FieldHeadimg, field.TypeString, value)
- }
- if value, ok := cu.mutation.Sex(); ok {
- _spec.SetField(contact.FieldSex, field.TypeInt, value)
- }
- if value, ok := cu.mutation.AddedSex(); ok {
- _spec.AddField(contact.FieldSex, field.TypeInt, value)
- }
- if value, ok := cu.mutation.Starrole(); ok {
- _spec.SetField(contact.FieldStarrole, field.TypeString, value)
- }
- if value, ok := cu.mutation.Dontseeit(); ok {
- _spec.SetField(contact.FieldDontseeit, field.TypeInt, value)
- }
- if value, ok := cu.mutation.AddedDontseeit(); ok {
- _spec.AddField(contact.FieldDontseeit, field.TypeInt, value)
- }
- if value, ok := cu.mutation.Dontseeme(); ok {
- _spec.SetField(contact.FieldDontseeme, field.TypeInt, value)
- }
- if value, ok := cu.mutation.AddedDontseeme(); ok {
- _spec.AddField(contact.FieldDontseeme, field.TypeInt, value)
- }
- if value, ok := cu.mutation.Lag(); ok {
- _spec.SetField(contact.FieldLag, field.TypeString, value)
- }
- if value, ok := cu.mutation.Gid(); ok {
- _spec.SetField(contact.FieldGid, field.TypeString, value)
- }
- if value, ok := cu.mutation.Gname(); ok {
- _spec.SetField(contact.FieldGname, field.TypeString, value)
- }
- if value, ok := cu.mutation.V3(); ok {
- _spec.SetField(contact.FieldV3, field.TypeString, value)
- }
- if value, ok := cu.mutation.OrganizationID(); ok {
- _spec.SetField(contact.FieldOrganizationID, field.TypeUint64, value)
- }
- if value, ok := cu.mutation.AddedOrganizationID(); ok {
- _spec.AddField(contact.FieldOrganizationID, field.TypeUint64, value)
- }
- if cu.mutation.OrganizationIDCleared() {
- _spec.ClearField(contact.FieldOrganizationID, field.TypeUint64)
- }
- if cu.mutation.ContactRelationshipsCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactRelationshipsTable,
- Columns: []string{contact.ContactRelationshipsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := cu.mutation.RemovedContactRelationshipsIDs(); len(nodes) > 0 && !cu.mutation.ContactRelationshipsCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactRelationshipsTable,
- Columns: []string{contact.ContactRelationshipsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := cu.mutation.ContactRelationshipsIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactRelationshipsTable,
- Columns: []string{contact.ContactRelationshipsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if cu.mutation.ContactMessagesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactMessagesTable,
- Columns: []string{contact.ContactMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := cu.mutation.RemovedContactMessagesIDs(); len(nodes) > 0 && !cu.mutation.ContactMessagesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactMessagesTable,
- Columns: []string{contact.ContactMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := cu.mutation.ContactMessagesIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactMessagesTable,
- Columns: []string{contact.ContactMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{contact.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return 0, err
- }
- cu.mutation.done = true
- return n, nil
- }
- // ContactUpdateOne is the builder for updating a single Contact entity.
- type ContactUpdateOne struct {
- config
- fields []string
- hooks []Hook
- mutation *ContactMutation
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (cuo *ContactUpdateOne) SetUpdatedAt(t time.Time) *ContactUpdateOne {
- cuo.mutation.SetUpdatedAt(t)
- return cuo
- }
- // SetStatus sets the "status" field.
- func (cuo *ContactUpdateOne) SetStatus(u uint8) *ContactUpdateOne {
- cuo.mutation.ResetStatus()
- cuo.mutation.SetStatus(u)
- return cuo
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableStatus(u *uint8) *ContactUpdateOne {
- if u != nil {
- cuo.SetStatus(*u)
- }
- return cuo
- }
- // AddStatus adds u to the "status" field.
- func (cuo *ContactUpdateOne) AddStatus(u int8) *ContactUpdateOne {
- cuo.mutation.AddStatus(u)
- return cuo
- }
- // ClearStatus clears the value of the "status" field.
- func (cuo *ContactUpdateOne) ClearStatus() *ContactUpdateOne {
- cuo.mutation.ClearStatus()
- return cuo
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (cuo *ContactUpdateOne) SetDeletedAt(t time.Time) *ContactUpdateOne {
- cuo.mutation.SetDeletedAt(t)
- return cuo
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableDeletedAt(t *time.Time) *ContactUpdateOne {
- if t != nil {
- cuo.SetDeletedAt(*t)
- }
- return cuo
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (cuo *ContactUpdateOne) ClearDeletedAt() *ContactUpdateOne {
- cuo.mutation.ClearDeletedAt()
- return cuo
- }
- // SetWxWxid sets the "wx_wxid" field.
- func (cuo *ContactUpdateOne) SetWxWxid(s string) *ContactUpdateOne {
- cuo.mutation.SetWxWxid(s)
- return cuo
- }
- // SetNillableWxWxid sets the "wx_wxid" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableWxWxid(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetWxWxid(*s)
- }
- return cuo
- }
- // SetType sets the "type" field.
- func (cuo *ContactUpdateOne) SetType(i int) *ContactUpdateOne {
- cuo.mutation.ResetType()
- cuo.mutation.SetType(i)
- return cuo
- }
- // SetNillableType sets the "type" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableType(i *int) *ContactUpdateOne {
- if i != nil {
- cuo.SetType(*i)
- }
- return cuo
- }
- // AddType adds i to the "type" field.
- func (cuo *ContactUpdateOne) AddType(i int) *ContactUpdateOne {
- cuo.mutation.AddType(i)
- return cuo
- }
- // ClearType clears the value of the "type" field.
- func (cuo *ContactUpdateOne) ClearType() *ContactUpdateOne {
- cuo.mutation.ClearType()
- return cuo
- }
- // SetWxid sets the "wxid" field.
- func (cuo *ContactUpdateOne) SetWxid(s string) *ContactUpdateOne {
- cuo.mutation.SetWxid(s)
- return cuo
- }
- // SetNillableWxid sets the "wxid" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableWxid(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetWxid(*s)
- }
- return cuo
- }
- // SetAccount sets the "account" field.
- func (cuo *ContactUpdateOne) SetAccount(s string) *ContactUpdateOne {
- cuo.mutation.SetAccount(s)
- return cuo
- }
- // SetNillableAccount sets the "account" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableAccount(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetAccount(*s)
- }
- return cuo
- }
- // SetNickname sets the "nickname" field.
- func (cuo *ContactUpdateOne) SetNickname(s string) *ContactUpdateOne {
- cuo.mutation.SetNickname(s)
- return cuo
- }
- // SetNillableNickname sets the "nickname" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableNickname(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetNickname(*s)
- }
- return cuo
- }
- // SetMarkname sets the "markname" field.
- func (cuo *ContactUpdateOne) SetMarkname(s string) *ContactUpdateOne {
- cuo.mutation.SetMarkname(s)
- return cuo
- }
- // SetNillableMarkname sets the "markname" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableMarkname(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetMarkname(*s)
- }
- return cuo
- }
- // SetHeadimg sets the "headimg" field.
- func (cuo *ContactUpdateOne) SetHeadimg(s string) *ContactUpdateOne {
- cuo.mutation.SetHeadimg(s)
- return cuo
- }
- // SetNillableHeadimg sets the "headimg" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableHeadimg(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetHeadimg(*s)
- }
- return cuo
- }
- // SetSex sets the "sex" field.
- func (cuo *ContactUpdateOne) SetSex(i int) *ContactUpdateOne {
- cuo.mutation.ResetSex()
- cuo.mutation.SetSex(i)
- return cuo
- }
- // SetNillableSex sets the "sex" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableSex(i *int) *ContactUpdateOne {
- if i != nil {
- cuo.SetSex(*i)
- }
- return cuo
- }
- // AddSex adds i to the "sex" field.
- func (cuo *ContactUpdateOne) AddSex(i int) *ContactUpdateOne {
- cuo.mutation.AddSex(i)
- return cuo
- }
- // SetStarrole sets the "starrole" field.
- func (cuo *ContactUpdateOne) SetStarrole(s string) *ContactUpdateOne {
- cuo.mutation.SetStarrole(s)
- return cuo
- }
- // SetNillableStarrole sets the "starrole" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableStarrole(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetStarrole(*s)
- }
- return cuo
- }
- // SetDontseeit sets the "dontseeit" field.
- func (cuo *ContactUpdateOne) SetDontseeit(i int) *ContactUpdateOne {
- cuo.mutation.ResetDontseeit()
- cuo.mutation.SetDontseeit(i)
- return cuo
- }
- // SetNillableDontseeit sets the "dontseeit" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableDontseeit(i *int) *ContactUpdateOne {
- if i != nil {
- cuo.SetDontseeit(*i)
- }
- return cuo
- }
- // AddDontseeit adds i to the "dontseeit" field.
- func (cuo *ContactUpdateOne) AddDontseeit(i int) *ContactUpdateOne {
- cuo.mutation.AddDontseeit(i)
- return cuo
- }
- // SetDontseeme sets the "dontseeme" field.
- func (cuo *ContactUpdateOne) SetDontseeme(i int) *ContactUpdateOne {
- cuo.mutation.ResetDontseeme()
- cuo.mutation.SetDontseeme(i)
- return cuo
- }
- // SetNillableDontseeme sets the "dontseeme" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableDontseeme(i *int) *ContactUpdateOne {
- if i != nil {
- cuo.SetDontseeme(*i)
- }
- return cuo
- }
- // AddDontseeme adds i to the "dontseeme" field.
- func (cuo *ContactUpdateOne) AddDontseeme(i int) *ContactUpdateOne {
- cuo.mutation.AddDontseeme(i)
- return cuo
- }
- // SetLag sets the "lag" field.
- func (cuo *ContactUpdateOne) SetLag(s string) *ContactUpdateOne {
- cuo.mutation.SetLag(s)
- return cuo
- }
- // SetNillableLag sets the "lag" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableLag(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetLag(*s)
- }
- return cuo
- }
- // SetGid sets the "gid" field.
- func (cuo *ContactUpdateOne) SetGid(s string) *ContactUpdateOne {
- cuo.mutation.SetGid(s)
- return cuo
- }
- // SetNillableGid sets the "gid" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableGid(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetGid(*s)
- }
- return cuo
- }
- // SetGname sets the "gname" field.
- func (cuo *ContactUpdateOne) SetGname(s string) *ContactUpdateOne {
- cuo.mutation.SetGname(s)
- return cuo
- }
- // SetNillableGname sets the "gname" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableGname(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetGname(*s)
- }
- return cuo
- }
- // SetV3 sets the "v3" field.
- func (cuo *ContactUpdateOne) SetV3(s string) *ContactUpdateOne {
- cuo.mutation.SetV3(s)
- return cuo
- }
- // SetNillableV3 sets the "v3" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableV3(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetV3(*s)
- }
- return cuo
- }
- // SetOrganizationID sets the "organization_id" field.
- func (cuo *ContactUpdateOne) SetOrganizationID(u uint64) *ContactUpdateOne {
- cuo.mutation.ResetOrganizationID()
- cuo.mutation.SetOrganizationID(u)
- return cuo
- }
- // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableOrganizationID(u *uint64) *ContactUpdateOne {
- if u != nil {
- cuo.SetOrganizationID(*u)
- }
- return cuo
- }
- // AddOrganizationID adds u to the "organization_id" field.
- func (cuo *ContactUpdateOne) AddOrganizationID(u int64) *ContactUpdateOne {
- cuo.mutation.AddOrganizationID(u)
- return cuo
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (cuo *ContactUpdateOne) ClearOrganizationID() *ContactUpdateOne {
- cuo.mutation.ClearOrganizationID()
- return cuo
- }
- // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by IDs.
- func (cuo *ContactUpdateOne) AddContactRelationshipIDs(ids ...uint64) *ContactUpdateOne {
- cuo.mutation.AddContactRelationshipIDs(ids...)
- return cuo
- }
- // AddContactRelationships adds the "contact_relationships" edges to the LabelRelationship entity.
- func (cuo *ContactUpdateOne) AddContactRelationships(l ...*LabelRelationship) *ContactUpdateOne {
- ids := make([]uint64, len(l))
- for i := range l {
- ids[i] = l[i].ID
- }
- return cuo.AddContactRelationshipIDs(ids...)
- }
- // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by IDs.
- func (cuo *ContactUpdateOne) AddContactMessageIDs(ids ...uint64) *ContactUpdateOne {
- cuo.mutation.AddContactMessageIDs(ids...)
- return cuo
- }
- // AddContactMessages adds the "contact_messages" edges to the MessageRecords entity.
- func (cuo *ContactUpdateOne) AddContactMessages(m ...*MessageRecords) *ContactUpdateOne {
- ids := make([]uint64, len(m))
- for i := range m {
- ids[i] = m[i].ID
- }
- return cuo.AddContactMessageIDs(ids...)
- }
- // Mutation returns the ContactMutation object of the builder.
- func (cuo *ContactUpdateOne) Mutation() *ContactMutation {
- return cuo.mutation
- }
- // ClearContactRelationships clears all "contact_relationships" edges to the LabelRelationship entity.
- func (cuo *ContactUpdateOne) ClearContactRelationships() *ContactUpdateOne {
- cuo.mutation.ClearContactRelationships()
- return cuo
- }
- // RemoveContactRelationshipIDs removes the "contact_relationships" edge to LabelRelationship entities by IDs.
- func (cuo *ContactUpdateOne) RemoveContactRelationshipIDs(ids ...uint64) *ContactUpdateOne {
- cuo.mutation.RemoveContactRelationshipIDs(ids...)
- return cuo
- }
- // RemoveContactRelationships removes "contact_relationships" edges to LabelRelationship entities.
- func (cuo *ContactUpdateOne) RemoveContactRelationships(l ...*LabelRelationship) *ContactUpdateOne {
- ids := make([]uint64, len(l))
- for i := range l {
- ids[i] = l[i].ID
- }
- return cuo.RemoveContactRelationshipIDs(ids...)
- }
- // ClearContactMessages clears all "contact_messages" edges to the MessageRecords entity.
- func (cuo *ContactUpdateOne) ClearContactMessages() *ContactUpdateOne {
- cuo.mutation.ClearContactMessages()
- return cuo
- }
- // RemoveContactMessageIDs removes the "contact_messages" edge to MessageRecords entities by IDs.
- func (cuo *ContactUpdateOne) RemoveContactMessageIDs(ids ...uint64) *ContactUpdateOne {
- cuo.mutation.RemoveContactMessageIDs(ids...)
- return cuo
- }
- // RemoveContactMessages removes "contact_messages" edges to MessageRecords entities.
- func (cuo *ContactUpdateOne) RemoveContactMessages(m ...*MessageRecords) *ContactUpdateOne {
- ids := make([]uint64, len(m))
- for i := range m {
- ids[i] = m[i].ID
- }
- return cuo.RemoveContactMessageIDs(ids...)
- }
- // Where appends a list predicates to the ContactUpdate builder.
- func (cuo *ContactUpdateOne) Where(ps ...predicate.Contact) *ContactUpdateOne {
- cuo.mutation.Where(ps...)
- return cuo
- }
- // Select allows selecting one or more fields (columns) of the returned entity.
- // The default is selecting all fields defined in the entity schema.
- func (cuo *ContactUpdateOne) Select(field string, fields ...string) *ContactUpdateOne {
- cuo.fields = append([]string{field}, fields...)
- return cuo
- }
- // Save executes the query and returns the updated Contact entity.
- func (cuo *ContactUpdateOne) Save(ctx context.Context) (*Contact, error) {
- if err := cuo.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, cuo.sqlSave, cuo.mutation, cuo.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (cuo *ContactUpdateOne) SaveX(ctx context.Context) *Contact {
- node, err := cuo.Save(ctx)
- if err != nil {
- panic(err)
- }
- return node
- }
- // Exec executes the query on the entity.
- func (cuo *ContactUpdateOne) Exec(ctx context.Context) error {
- _, err := cuo.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (cuo *ContactUpdateOne) ExecX(ctx context.Context) {
- if err := cuo.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (cuo *ContactUpdateOne) defaults() error {
- if _, ok := cuo.mutation.UpdatedAt(); !ok {
- if contact.UpdateDefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized contact.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := contact.UpdateDefaultUpdatedAt()
- cuo.mutation.SetUpdatedAt(v)
- }
- return nil
- }
- func (cuo *ContactUpdateOne) sqlSave(ctx context.Context) (_node *Contact, err error) {
- _spec := sqlgraph.NewUpdateSpec(contact.Table, contact.Columns, sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64))
- id, ok := cuo.mutation.ID()
- if !ok {
- return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Contact.id" for update`)}
- }
- _spec.Node.ID.Value = id
- if fields := cuo.fields; len(fields) > 0 {
- _spec.Node.Columns = make([]string, 0, len(fields))
- _spec.Node.Columns = append(_spec.Node.Columns, contact.FieldID)
- for _, f := range fields {
- if !contact.ValidColumn(f) {
- return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
- }
- if f != contact.FieldID {
- _spec.Node.Columns = append(_spec.Node.Columns, f)
- }
- }
- }
- if ps := cuo.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := cuo.mutation.UpdatedAt(); ok {
- _spec.SetField(contact.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := cuo.mutation.Status(); ok {
- _spec.SetField(contact.FieldStatus, field.TypeUint8, value)
- }
- if value, ok := cuo.mutation.AddedStatus(); ok {
- _spec.AddField(contact.FieldStatus, field.TypeUint8, value)
- }
- if cuo.mutation.StatusCleared() {
- _spec.ClearField(contact.FieldStatus, field.TypeUint8)
- }
- if value, ok := cuo.mutation.DeletedAt(); ok {
- _spec.SetField(contact.FieldDeletedAt, field.TypeTime, value)
- }
- if cuo.mutation.DeletedAtCleared() {
- _spec.ClearField(contact.FieldDeletedAt, field.TypeTime)
- }
- if value, ok := cuo.mutation.WxWxid(); ok {
- _spec.SetField(contact.FieldWxWxid, field.TypeString, value)
- }
- if value, ok := cuo.mutation.GetType(); ok {
- _spec.SetField(contact.FieldType, field.TypeInt, value)
- }
- if value, ok := cuo.mutation.AddedType(); ok {
- _spec.AddField(contact.FieldType, field.TypeInt, value)
- }
- if cuo.mutation.TypeCleared() {
- _spec.ClearField(contact.FieldType, field.TypeInt)
- }
- if value, ok := cuo.mutation.Wxid(); ok {
- _spec.SetField(contact.FieldWxid, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Account(); ok {
- _spec.SetField(contact.FieldAccount, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Nickname(); ok {
- _spec.SetField(contact.FieldNickname, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Markname(); ok {
- _spec.SetField(contact.FieldMarkname, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Headimg(); ok {
- _spec.SetField(contact.FieldHeadimg, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Sex(); ok {
- _spec.SetField(contact.FieldSex, field.TypeInt, value)
- }
- if value, ok := cuo.mutation.AddedSex(); ok {
- _spec.AddField(contact.FieldSex, field.TypeInt, value)
- }
- if value, ok := cuo.mutation.Starrole(); ok {
- _spec.SetField(contact.FieldStarrole, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Dontseeit(); ok {
- _spec.SetField(contact.FieldDontseeit, field.TypeInt, value)
- }
- if value, ok := cuo.mutation.AddedDontseeit(); ok {
- _spec.AddField(contact.FieldDontseeit, field.TypeInt, value)
- }
- if value, ok := cuo.mutation.Dontseeme(); ok {
- _spec.SetField(contact.FieldDontseeme, field.TypeInt, value)
- }
- if value, ok := cuo.mutation.AddedDontseeme(); ok {
- _spec.AddField(contact.FieldDontseeme, field.TypeInt, value)
- }
- if value, ok := cuo.mutation.Lag(); ok {
- _spec.SetField(contact.FieldLag, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Gid(); ok {
- _spec.SetField(contact.FieldGid, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Gname(); ok {
- _spec.SetField(contact.FieldGname, field.TypeString, value)
- }
- if value, ok := cuo.mutation.V3(); ok {
- _spec.SetField(contact.FieldV3, field.TypeString, value)
- }
- if value, ok := cuo.mutation.OrganizationID(); ok {
- _spec.SetField(contact.FieldOrganizationID, field.TypeUint64, value)
- }
- if value, ok := cuo.mutation.AddedOrganizationID(); ok {
- _spec.AddField(contact.FieldOrganizationID, field.TypeUint64, value)
- }
- if cuo.mutation.OrganizationIDCleared() {
- _spec.ClearField(contact.FieldOrganizationID, field.TypeUint64)
- }
- if cuo.mutation.ContactRelationshipsCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactRelationshipsTable,
- Columns: []string{contact.ContactRelationshipsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := cuo.mutation.RemovedContactRelationshipsIDs(); len(nodes) > 0 && !cuo.mutation.ContactRelationshipsCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactRelationshipsTable,
- Columns: []string{contact.ContactRelationshipsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := cuo.mutation.ContactRelationshipsIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactRelationshipsTable,
- Columns: []string{contact.ContactRelationshipsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if cuo.mutation.ContactMessagesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactMessagesTable,
- Columns: []string{contact.ContactMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := cuo.mutation.RemovedContactMessagesIDs(); len(nodes) > 0 && !cuo.mutation.ContactMessagesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactMessagesTable,
- Columns: []string{contact.ContactMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := cuo.mutation.ContactMessagesIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactMessagesTable,
- Columns: []string{contact.ContactMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- _node = &Contact{config: cuo.config}
- _spec.Assign = _node.assignValues
- _spec.ScanValues = _node.scanValues
- if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{contact.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- cuo.mutation.done = true
- return _node, nil
- }
|