123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "wechat-api/ent/contact"
- "wechat-api/ent/custom_types"
- "wechat-api/ent/messagerecords"
- "wechat-api/ent/predicate"
- "wechat-api/ent/sopnode"
- "wechat-api/ent/sopstage"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- )
- // MessageRecordsUpdate is the builder for updating MessageRecords entities.
- type MessageRecordsUpdate struct {
- config
- hooks []Hook
- mutation *MessageRecordsMutation
- }
- // Where appends a list predicates to the MessageRecordsUpdate builder.
- func (mru *MessageRecordsUpdate) Where(ps ...predicate.MessageRecords) *MessageRecordsUpdate {
- mru.mutation.Where(ps...)
- return mru
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (mru *MessageRecordsUpdate) SetUpdatedAt(t time.Time) *MessageRecordsUpdate {
- mru.mutation.SetUpdatedAt(t)
- return mru
- }
- // SetStatus sets the "status" field.
- func (mru *MessageRecordsUpdate) SetStatus(u uint8) *MessageRecordsUpdate {
- mru.mutation.ResetStatus()
- mru.mutation.SetStatus(u)
- return mru
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (mru *MessageRecordsUpdate) SetNillableStatus(u *uint8) *MessageRecordsUpdate {
- if u != nil {
- mru.SetStatus(*u)
- }
- return mru
- }
- // AddStatus adds u to the "status" field.
- func (mru *MessageRecordsUpdate) AddStatus(u int8) *MessageRecordsUpdate {
- mru.mutation.AddStatus(u)
- return mru
- }
- // ClearStatus clears the value of the "status" field.
- func (mru *MessageRecordsUpdate) ClearStatus() *MessageRecordsUpdate {
- mru.mutation.ClearStatus()
- return mru
- }
- // SetBotWxid sets the "bot_wxid" field.
- func (mru *MessageRecordsUpdate) SetBotWxid(s string) *MessageRecordsUpdate {
- mru.mutation.SetBotWxid(s)
- return mru
- }
- // SetNillableBotWxid sets the "bot_wxid" field if the given value is not nil.
- func (mru *MessageRecordsUpdate) SetNillableBotWxid(s *string) *MessageRecordsUpdate {
- if s != nil {
- mru.SetBotWxid(*s)
- }
- return mru
- }
- // SetContactID sets the "contact_id" field.
- func (mru *MessageRecordsUpdate) SetContactID(u uint64) *MessageRecordsUpdate {
- mru.mutation.SetContactID(u)
- return mru
- }
- // SetNillableContactID sets the "contact_id" field if the given value is not nil.
- func (mru *MessageRecordsUpdate) SetNillableContactID(u *uint64) *MessageRecordsUpdate {
- if u != nil {
- mru.SetContactID(*u)
- }
- return mru
- }
- // ClearContactID clears the value of the "contact_id" field.
- func (mru *MessageRecordsUpdate) ClearContactID() *MessageRecordsUpdate {
- mru.mutation.ClearContactID()
- return mru
- }
- // SetContactType sets the "contact_type" field.
- func (mru *MessageRecordsUpdate) SetContactType(i int) *MessageRecordsUpdate {
- mru.mutation.ResetContactType()
- mru.mutation.SetContactType(i)
- return mru
- }
- // SetNillableContactType sets the "contact_type" field if the given value is not nil.
- func (mru *MessageRecordsUpdate) SetNillableContactType(i *int) *MessageRecordsUpdate {
- if i != nil {
- mru.SetContactType(*i)
- }
- return mru
- }
- // AddContactType adds i to the "contact_type" field.
- func (mru *MessageRecordsUpdate) AddContactType(i int) *MessageRecordsUpdate {
- mru.mutation.AddContactType(i)
- return mru
- }
- // SetContactWxid sets the "contact_wxid" field.
- func (mru *MessageRecordsUpdate) SetContactWxid(s string) *MessageRecordsUpdate {
- mru.mutation.SetContactWxid(s)
- return mru
- }
- // SetNillableContactWxid sets the "contact_wxid" field if the given value is not nil.
- func (mru *MessageRecordsUpdate) SetNillableContactWxid(s *string) *MessageRecordsUpdate {
- if s != nil {
- mru.SetContactWxid(*s)
- }
- return mru
- }
- // SetContentType sets the "content_type" field.
- func (mru *MessageRecordsUpdate) SetContentType(i int) *MessageRecordsUpdate {
- mru.mutation.ResetContentType()
- mru.mutation.SetContentType(i)
- return mru
- }
- // SetNillableContentType sets the "content_type" field if the given value is not nil.
- func (mru *MessageRecordsUpdate) SetNillableContentType(i *int) *MessageRecordsUpdate {
- if i != nil {
- mru.SetContentType(*i)
- }
- return mru
- }
- // AddContentType adds i to the "content_type" field.
- func (mru *MessageRecordsUpdate) AddContentType(i int) *MessageRecordsUpdate {
- mru.mutation.AddContentType(i)
- return mru
- }
- // SetContent sets the "content" field.
- func (mru *MessageRecordsUpdate) SetContent(s string) *MessageRecordsUpdate {
- mru.mutation.SetContent(s)
- return mru
- }
- // SetNillableContent sets the "content" field if the given value is not nil.
- func (mru *MessageRecordsUpdate) SetNillableContent(s *string) *MessageRecordsUpdate {
- if s != nil {
- mru.SetContent(*s)
- }
- return mru
- }
- // SetMeta sets the "meta" field.
- func (mru *MessageRecordsUpdate) SetMeta(ct custom_types.Meta) *MessageRecordsUpdate {
- mru.mutation.SetMeta(ct)
- return mru
- }
- // SetNillableMeta sets the "meta" field if the given value is not nil.
- func (mru *MessageRecordsUpdate) SetNillableMeta(ct *custom_types.Meta) *MessageRecordsUpdate {
- if ct != nil {
- mru.SetMeta(*ct)
- }
- return mru
- }
- // ClearMeta clears the value of the "meta" field.
- func (mru *MessageRecordsUpdate) ClearMeta() *MessageRecordsUpdate {
- mru.mutation.ClearMeta()
- return mru
- }
- // SetErrorDetail sets the "error_detail" field.
- func (mru *MessageRecordsUpdate) SetErrorDetail(s string) *MessageRecordsUpdate {
- mru.mutation.SetErrorDetail(s)
- return mru
- }
- // SetNillableErrorDetail sets the "error_detail" field if the given value is not nil.
- func (mru *MessageRecordsUpdate) SetNillableErrorDetail(s *string) *MessageRecordsUpdate {
- if s != nil {
- mru.SetErrorDetail(*s)
- }
- return mru
- }
- // SetSendTime sets the "send_time" field.
- func (mru *MessageRecordsUpdate) SetSendTime(t time.Time) *MessageRecordsUpdate {
- mru.mutation.SetSendTime(t)
- return mru
- }
- // SetNillableSendTime sets the "send_time" field if the given value is not nil.
- func (mru *MessageRecordsUpdate) SetNillableSendTime(t *time.Time) *MessageRecordsUpdate {
- if t != nil {
- mru.SetSendTime(*t)
- }
- return mru
- }
- // ClearSendTime clears the value of the "send_time" field.
- func (mru *MessageRecordsUpdate) ClearSendTime() *MessageRecordsUpdate {
- mru.mutation.ClearSendTime()
- return mru
- }
- // SetSourceType sets the "source_type" field.
- func (mru *MessageRecordsUpdate) SetSourceType(i int) *MessageRecordsUpdate {
- mru.mutation.ResetSourceType()
- mru.mutation.SetSourceType(i)
- return mru
- }
- // SetNillableSourceType sets the "source_type" field if the given value is not nil.
- func (mru *MessageRecordsUpdate) SetNillableSourceType(i *int) *MessageRecordsUpdate {
- if i != nil {
- mru.SetSourceType(*i)
- }
- return mru
- }
- // AddSourceType adds i to the "source_type" field.
- func (mru *MessageRecordsUpdate) AddSourceType(i int) *MessageRecordsUpdate {
- mru.mutation.AddSourceType(i)
- return mru
- }
- // SetSourceID sets the "source_id" field.
- func (mru *MessageRecordsUpdate) SetSourceID(u uint64) *MessageRecordsUpdate {
- mru.mutation.SetSourceID(u)
- return mru
- }
- // SetNillableSourceID sets the "source_id" field if the given value is not nil.
- func (mru *MessageRecordsUpdate) SetNillableSourceID(u *uint64) *MessageRecordsUpdate {
- if u != nil {
- mru.SetSourceID(*u)
- }
- return mru
- }
- // ClearSourceID clears the value of the "source_id" field.
- func (mru *MessageRecordsUpdate) ClearSourceID() *MessageRecordsUpdate {
- mru.mutation.ClearSourceID()
- return mru
- }
- // SetSubSourceID sets the "sub_source_id" field.
- func (mru *MessageRecordsUpdate) SetSubSourceID(u uint64) *MessageRecordsUpdate {
- mru.mutation.SetSubSourceID(u)
- return mru
- }
- // SetNillableSubSourceID sets the "sub_source_id" field if the given value is not nil.
- func (mru *MessageRecordsUpdate) SetNillableSubSourceID(u *uint64) *MessageRecordsUpdate {
- if u != nil {
- mru.SetSubSourceID(*u)
- }
- return mru
- }
- // ClearSubSourceID clears the value of the "sub_source_id" field.
- func (mru *MessageRecordsUpdate) ClearSubSourceID() *MessageRecordsUpdate {
- mru.mutation.ClearSubSourceID()
- return mru
- }
- // SetOrganizationID sets the "organization_id" field.
- func (mru *MessageRecordsUpdate) SetOrganizationID(u uint64) *MessageRecordsUpdate {
- mru.mutation.ResetOrganizationID()
- mru.mutation.SetOrganizationID(u)
- return mru
- }
- // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
- func (mru *MessageRecordsUpdate) SetNillableOrganizationID(u *uint64) *MessageRecordsUpdate {
- if u != nil {
- mru.SetOrganizationID(*u)
- }
- return mru
- }
- // AddOrganizationID adds u to the "organization_id" field.
- func (mru *MessageRecordsUpdate) AddOrganizationID(u int64) *MessageRecordsUpdate {
- mru.mutation.AddOrganizationID(u)
- return mru
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (mru *MessageRecordsUpdate) ClearOrganizationID() *MessageRecordsUpdate {
- mru.mutation.ClearOrganizationID()
- return mru
- }
- // SetSopStageID sets the "sop_stage" edge to the SopStage entity by ID.
- func (mru *MessageRecordsUpdate) SetSopStageID(id uint64) *MessageRecordsUpdate {
- mru.mutation.SetSopStageID(id)
- return mru
- }
- // SetNillableSopStageID sets the "sop_stage" edge to the SopStage entity by ID if the given value is not nil.
- func (mru *MessageRecordsUpdate) SetNillableSopStageID(id *uint64) *MessageRecordsUpdate {
- if id != nil {
- mru = mru.SetSopStageID(*id)
- }
- return mru
- }
- // SetSopStage sets the "sop_stage" edge to the SopStage entity.
- func (mru *MessageRecordsUpdate) SetSopStage(s *SopStage) *MessageRecordsUpdate {
- return mru.SetSopStageID(s.ID)
- }
- // SetSopNodeID sets the "sop_node" edge to the SopNode entity by ID.
- func (mru *MessageRecordsUpdate) SetSopNodeID(id uint64) *MessageRecordsUpdate {
- mru.mutation.SetSopNodeID(id)
- return mru
- }
- // SetNillableSopNodeID sets the "sop_node" edge to the SopNode entity by ID if the given value is not nil.
- func (mru *MessageRecordsUpdate) SetNillableSopNodeID(id *uint64) *MessageRecordsUpdate {
- if id != nil {
- mru = mru.SetSopNodeID(*id)
- }
- return mru
- }
- // SetSopNode sets the "sop_node" edge to the SopNode entity.
- func (mru *MessageRecordsUpdate) SetSopNode(s *SopNode) *MessageRecordsUpdate {
- return mru.SetSopNodeID(s.ID)
- }
- // SetMessageContactID sets the "message_contact" edge to the Contact entity by ID.
- func (mru *MessageRecordsUpdate) SetMessageContactID(id uint64) *MessageRecordsUpdate {
- mru.mutation.SetMessageContactID(id)
- return mru
- }
- // SetNillableMessageContactID sets the "message_contact" edge to the Contact entity by ID if the given value is not nil.
- func (mru *MessageRecordsUpdate) SetNillableMessageContactID(id *uint64) *MessageRecordsUpdate {
- if id != nil {
- mru = mru.SetMessageContactID(*id)
- }
- return mru
- }
- // SetMessageContact sets the "message_contact" edge to the Contact entity.
- func (mru *MessageRecordsUpdate) SetMessageContact(c *Contact) *MessageRecordsUpdate {
- return mru.SetMessageContactID(c.ID)
- }
- // Mutation returns the MessageRecordsMutation object of the builder.
- func (mru *MessageRecordsUpdate) Mutation() *MessageRecordsMutation {
- return mru.mutation
- }
- // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
- func (mru *MessageRecordsUpdate) ClearSopStage() *MessageRecordsUpdate {
- mru.mutation.ClearSopStage()
- return mru
- }
- // ClearSopNode clears the "sop_node" edge to the SopNode entity.
- func (mru *MessageRecordsUpdate) ClearSopNode() *MessageRecordsUpdate {
- mru.mutation.ClearSopNode()
- return mru
- }
- // ClearMessageContact clears the "message_contact" edge to the Contact entity.
- func (mru *MessageRecordsUpdate) ClearMessageContact() *MessageRecordsUpdate {
- mru.mutation.ClearMessageContact()
- return mru
- }
- // Save executes the query and returns the number of nodes affected by the update operation.
- func (mru *MessageRecordsUpdate) Save(ctx context.Context) (int, error) {
- mru.defaults()
- return withHooks(ctx, mru.sqlSave, mru.mutation, mru.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (mru *MessageRecordsUpdate) SaveX(ctx context.Context) int {
- affected, err := mru.Save(ctx)
- if err != nil {
- panic(err)
- }
- return affected
- }
- // Exec executes the query.
- func (mru *MessageRecordsUpdate) Exec(ctx context.Context) error {
- _, err := mru.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (mru *MessageRecordsUpdate) ExecX(ctx context.Context) {
- if err := mru.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (mru *MessageRecordsUpdate) defaults() {
- if _, ok := mru.mutation.UpdatedAt(); !ok {
- v := messagerecords.UpdateDefaultUpdatedAt()
- mru.mutation.SetUpdatedAt(v)
- }
- }
- func (mru *MessageRecordsUpdate) sqlSave(ctx context.Context) (n int, err error) {
- _spec := sqlgraph.NewUpdateSpec(messagerecords.Table, messagerecords.Columns, sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64))
- if ps := mru.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := mru.mutation.UpdatedAt(); ok {
- _spec.SetField(messagerecords.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := mru.mutation.Status(); ok {
- _spec.SetField(messagerecords.FieldStatus, field.TypeUint8, value)
- }
- if value, ok := mru.mutation.AddedStatus(); ok {
- _spec.AddField(messagerecords.FieldStatus, field.TypeUint8, value)
- }
- if mru.mutation.StatusCleared() {
- _spec.ClearField(messagerecords.FieldStatus, field.TypeUint8)
- }
- if value, ok := mru.mutation.BotWxid(); ok {
- _spec.SetField(messagerecords.FieldBotWxid, field.TypeString, value)
- }
- if value, ok := mru.mutation.ContactType(); ok {
- _spec.SetField(messagerecords.FieldContactType, field.TypeInt, value)
- }
- if value, ok := mru.mutation.AddedContactType(); ok {
- _spec.AddField(messagerecords.FieldContactType, field.TypeInt, value)
- }
- if value, ok := mru.mutation.ContactWxid(); ok {
- _spec.SetField(messagerecords.FieldContactWxid, field.TypeString, value)
- }
- if value, ok := mru.mutation.ContentType(); ok {
- _spec.SetField(messagerecords.FieldContentType, field.TypeInt, value)
- }
- if value, ok := mru.mutation.AddedContentType(); ok {
- _spec.AddField(messagerecords.FieldContentType, field.TypeInt, value)
- }
- if value, ok := mru.mutation.Content(); ok {
- _spec.SetField(messagerecords.FieldContent, field.TypeString, value)
- }
- if value, ok := mru.mutation.Meta(); ok {
- _spec.SetField(messagerecords.FieldMeta, field.TypeJSON, value)
- }
- if mru.mutation.MetaCleared() {
- _spec.ClearField(messagerecords.FieldMeta, field.TypeJSON)
- }
- if value, ok := mru.mutation.ErrorDetail(); ok {
- _spec.SetField(messagerecords.FieldErrorDetail, field.TypeString, value)
- }
- if value, ok := mru.mutation.SendTime(); ok {
- _spec.SetField(messagerecords.FieldSendTime, field.TypeTime, value)
- }
- if mru.mutation.SendTimeCleared() {
- _spec.ClearField(messagerecords.FieldSendTime, field.TypeTime)
- }
- if value, ok := mru.mutation.SourceType(); ok {
- _spec.SetField(messagerecords.FieldSourceType, field.TypeInt, value)
- }
- if value, ok := mru.mutation.AddedSourceType(); ok {
- _spec.AddField(messagerecords.FieldSourceType, field.TypeInt, value)
- }
- if value, ok := mru.mutation.OrganizationID(); ok {
- _spec.SetField(messagerecords.FieldOrganizationID, field.TypeUint64, value)
- }
- if value, ok := mru.mutation.AddedOrganizationID(); ok {
- _spec.AddField(messagerecords.FieldOrganizationID, field.TypeUint64, value)
- }
- if mru.mutation.OrganizationIDCleared() {
- _spec.ClearField(messagerecords.FieldOrganizationID, field.TypeUint64)
- }
- if mru.mutation.SopStageCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: messagerecords.SopStageTable,
- Columns: []string{messagerecords.SopStageColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopstage.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := mru.mutation.SopStageIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: messagerecords.SopStageTable,
- Columns: []string{messagerecords.SopStageColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopstage.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if mru.mutation.SopNodeCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: messagerecords.SopNodeTable,
- Columns: []string{messagerecords.SopNodeColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := mru.mutation.SopNodeIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: messagerecords.SopNodeTable,
- Columns: []string{messagerecords.SopNodeColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if mru.mutation.MessageContactCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: messagerecords.MessageContactTable,
- Columns: []string{messagerecords.MessageContactColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := mru.mutation.MessageContactIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: messagerecords.MessageContactTable,
- Columns: []string{messagerecords.MessageContactColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(contact.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, mru.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{messagerecords.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return 0, err
- }
- mru.mutation.done = true
- return n, nil
- }
- // MessageRecordsUpdateOne is the builder for updating a single MessageRecords entity.
- type MessageRecordsUpdateOne struct {
- config
- fields []string
- hooks []Hook
- mutation *MessageRecordsMutation
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (mruo *MessageRecordsUpdateOne) SetUpdatedAt(t time.Time) *MessageRecordsUpdateOne {
- mruo.mutation.SetUpdatedAt(t)
- return mruo
- }
- // SetStatus sets the "status" field.
- func (mruo *MessageRecordsUpdateOne) SetStatus(u uint8) *MessageRecordsUpdateOne {
- mruo.mutation.ResetStatus()
- mruo.mutation.SetStatus(u)
- return mruo
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (mruo *MessageRecordsUpdateOne) SetNillableStatus(u *uint8) *MessageRecordsUpdateOne {
- if u != nil {
- mruo.SetStatus(*u)
- }
- return mruo
- }
- // AddStatus adds u to the "status" field.
- func (mruo *MessageRecordsUpdateOne) AddStatus(u int8) *MessageRecordsUpdateOne {
- mruo.mutation.AddStatus(u)
- return mruo
- }
- // ClearStatus clears the value of the "status" field.
- func (mruo *MessageRecordsUpdateOne) ClearStatus() *MessageRecordsUpdateOne {
- mruo.mutation.ClearStatus()
- return mruo
- }
- // SetBotWxid sets the "bot_wxid" field.
- func (mruo *MessageRecordsUpdateOne) SetBotWxid(s string) *MessageRecordsUpdateOne {
- mruo.mutation.SetBotWxid(s)
- return mruo
- }
- // SetNillableBotWxid sets the "bot_wxid" field if the given value is not nil.
- func (mruo *MessageRecordsUpdateOne) SetNillableBotWxid(s *string) *MessageRecordsUpdateOne {
- if s != nil {
- mruo.SetBotWxid(*s)
- }
- return mruo
- }
- // SetContactID sets the "contact_id" field.
- func (mruo *MessageRecordsUpdateOne) SetContactID(u uint64) *MessageRecordsUpdateOne {
- mruo.mutation.SetContactID(u)
- return mruo
- }
- // SetNillableContactID sets the "contact_id" field if the given value is not nil.
- func (mruo *MessageRecordsUpdateOne) SetNillableContactID(u *uint64) *MessageRecordsUpdateOne {
- if u != nil {
- mruo.SetContactID(*u)
- }
- return mruo
- }
- // ClearContactID clears the value of the "contact_id" field.
- func (mruo *MessageRecordsUpdateOne) ClearContactID() *MessageRecordsUpdateOne {
- mruo.mutation.ClearContactID()
- return mruo
- }
- // SetContactType sets the "contact_type" field.
- func (mruo *MessageRecordsUpdateOne) SetContactType(i int) *MessageRecordsUpdateOne {
- mruo.mutation.ResetContactType()
- mruo.mutation.SetContactType(i)
- return mruo
- }
- // SetNillableContactType sets the "contact_type" field if the given value is not nil.
- func (mruo *MessageRecordsUpdateOne) SetNillableContactType(i *int) *MessageRecordsUpdateOne {
- if i != nil {
- mruo.SetContactType(*i)
- }
- return mruo
- }
- // AddContactType adds i to the "contact_type" field.
- func (mruo *MessageRecordsUpdateOne) AddContactType(i int) *MessageRecordsUpdateOne {
- mruo.mutation.AddContactType(i)
- return mruo
- }
- // SetContactWxid sets the "contact_wxid" field.
- func (mruo *MessageRecordsUpdateOne) SetContactWxid(s string) *MessageRecordsUpdateOne {
- mruo.mutation.SetContactWxid(s)
- return mruo
- }
- // SetNillableContactWxid sets the "contact_wxid" field if the given value is not nil.
- func (mruo *MessageRecordsUpdateOne) SetNillableContactWxid(s *string) *MessageRecordsUpdateOne {
- if s != nil {
- mruo.SetContactWxid(*s)
- }
- return mruo
- }
- // SetContentType sets the "content_type" field.
- func (mruo *MessageRecordsUpdateOne) SetContentType(i int) *MessageRecordsUpdateOne {
- mruo.mutation.ResetContentType()
- mruo.mutation.SetContentType(i)
- return mruo
- }
- // SetNillableContentType sets the "content_type" field if the given value is not nil.
- func (mruo *MessageRecordsUpdateOne) SetNillableContentType(i *int) *MessageRecordsUpdateOne {
- if i != nil {
- mruo.SetContentType(*i)
- }
- return mruo
- }
- // AddContentType adds i to the "content_type" field.
- func (mruo *MessageRecordsUpdateOne) AddContentType(i int) *MessageRecordsUpdateOne {
- mruo.mutation.AddContentType(i)
- return mruo
- }
- // SetContent sets the "content" field.
- func (mruo *MessageRecordsUpdateOne) SetContent(s string) *MessageRecordsUpdateOne {
- mruo.mutation.SetContent(s)
- return mruo
- }
- // SetNillableContent sets the "content" field if the given value is not nil.
- func (mruo *MessageRecordsUpdateOne) SetNillableContent(s *string) *MessageRecordsUpdateOne {
- if s != nil {
- mruo.SetContent(*s)
- }
- return mruo
- }
- // SetMeta sets the "meta" field.
- func (mruo *MessageRecordsUpdateOne) SetMeta(ct custom_types.Meta) *MessageRecordsUpdateOne {
- mruo.mutation.SetMeta(ct)
- return mruo
- }
- // SetNillableMeta sets the "meta" field if the given value is not nil.
- func (mruo *MessageRecordsUpdateOne) SetNillableMeta(ct *custom_types.Meta) *MessageRecordsUpdateOne {
- if ct != nil {
- mruo.SetMeta(*ct)
- }
- return mruo
- }
- // ClearMeta clears the value of the "meta" field.
- func (mruo *MessageRecordsUpdateOne) ClearMeta() *MessageRecordsUpdateOne {
- mruo.mutation.ClearMeta()
- return mruo
- }
- // SetErrorDetail sets the "error_detail" field.
- func (mruo *MessageRecordsUpdateOne) SetErrorDetail(s string) *MessageRecordsUpdateOne {
- mruo.mutation.SetErrorDetail(s)
- return mruo
- }
- // SetNillableErrorDetail sets the "error_detail" field if the given value is not nil.
- func (mruo *MessageRecordsUpdateOne) SetNillableErrorDetail(s *string) *MessageRecordsUpdateOne {
- if s != nil {
- mruo.SetErrorDetail(*s)
- }
- return mruo
- }
- // SetSendTime sets the "send_time" field.
- func (mruo *MessageRecordsUpdateOne) SetSendTime(t time.Time) *MessageRecordsUpdateOne {
- mruo.mutation.SetSendTime(t)
- return mruo
- }
- // SetNillableSendTime sets the "send_time" field if the given value is not nil.
- func (mruo *MessageRecordsUpdateOne) SetNillableSendTime(t *time.Time) *MessageRecordsUpdateOne {
- if t != nil {
- mruo.SetSendTime(*t)
- }
- return mruo
- }
- // ClearSendTime clears the value of the "send_time" field.
- func (mruo *MessageRecordsUpdateOne) ClearSendTime() *MessageRecordsUpdateOne {
- mruo.mutation.ClearSendTime()
- return mruo
- }
- // SetSourceType sets the "source_type" field.
- func (mruo *MessageRecordsUpdateOne) SetSourceType(i int) *MessageRecordsUpdateOne {
- mruo.mutation.ResetSourceType()
- mruo.mutation.SetSourceType(i)
- return mruo
- }
- // SetNillableSourceType sets the "source_type" field if the given value is not nil.
- func (mruo *MessageRecordsUpdateOne) SetNillableSourceType(i *int) *MessageRecordsUpdateOne {
- if i != nil {
- mruo.SetSourceType(*i)
- }
- return mruo
- }
- // AddSourceType adds i to the "source_type" field.
- func (mruo *MessageRecordsUpdateOne) AddSourceType(i int) *MessageRecordsUpdateOne {
- mruo.mutation.AddSourceType(i)
- return mruo
- }
- // SetSourceID sets the "source_id" field.
- func (mruo *MessageRecordsUpdateOne) SetSourceID(u uint64) *MessageRecordsUpdateOne {
- mruo.mutation.SetSourceID(u)
- return mruo
- }
- // SetNillableSourceID sets the "source_id" field if the given value is not nil.
- func (mruo *MessageRecordsUpdateOne) SetNillableSourceID(u *uint64) *MessageRecordsUpdateOne {
- if u != nil {
- mruo.SetSourceID(*u)
- }
- return mruo
- }
- // ClearSourceID clears the value of the "source_id" field.
- func (mruo *MessageRecordsUpdateOne) ClearSourceID() *MessageRecordsUpdateOne {
- mruo.mutation.ClearSourceID()
- return mruo
- }
- // SetSubSourceID sets the "sub_source_id" field.
- func (mruo *MessageRecordsUpdateOne) SetSubSourceID(u uint64) *MessageRecordsUpdateOne {
- mruo.mutation.SetSubSourceID(u)
- return mruo
- }
- // SetNillableSubSourceID sets the "sub_source_id" field if the given value is not nil.
- func (mruo *MessageRecordsUpdateOne) SetNillableSubSourceID(u *uint64) *MessageRecordsUpdateOne {
- if u != nil {
- mruo.SetSubSourceID(*u)
- }
- return mruo
- }
- // ClearSubSourceID clears the value of the "sub_source_id" field.
- func (mruo *MessageRecordsUpdateOne) ClearSubSourceID() *MessageRecordsUpdateOne {
- mruo.mutation.ClearSubSourceID()
- return mruo
- }
- // SetOrganizationID sets the "organization_id" field.
- func (mruo *MessageRecordsUpdateOne) SetOrganizationID(u uint64) *MessageRecordsUpdateOne {
- mruo.mutation.ResetOrganizationID()
- mruo.mutation.SetOrganizationID(u)
- return mruo
- }
- // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
- func (mruo *MessageRecordsUpdateOne) SetNillableOrganizationID(u *uint64) *MessageRecordsUpdateOne {
- if u != nil {
- mruo.SetOrganizationID(*u)
- }
- return mruo
- }
- // AddOrganizationID adds u to the "organization_id" field.
- func (mruo *MessageRecordsUpdateOne) AddOrganizationID(u int64) *MessageRecordsUpdateOne {
- mruo.mutation.AddOrganizationID(u)
- return mruo
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (mruo *MessageRecordsUpdateOne) ClearOrganizationID() *MessageRecordsUpdateOne {
- mruo.mutation.ClearOrganizationID()
- return mruo
- }
- // SetSopStageID sets the "sop_stage" edge to the SopStage entity by ID.
- func (mruo *MessageRecordsUpdateOne) SetSopStageID(id uint64) *MessageRecordsUpdateOne {
- mruo.mutation.SetSopStageID(id)
- return mruo
- }
- // SetNillableSopStageID sets the "sop_stage" edge to the SopStage entity by ID if the given value is not nil.
- func (mruo *MessageRecordsUpdateOne) SetNillableSopStageID(id *uint64) *MessageRecordsUpdateOne {
- if id != nil {
- mruo = mruo.SetSopStageID(*id)
- }
- return mruo
- }
- // SetSopStage sets the "sop_stage" edge to the SopStage entity.
- func (mruo *MessageRecordsUpdateOne) SetSopStage(s *SopStage) *MessageRecordsUpdateOne {
- return mruo.SetSopStageID(s.ID)
- }
- // SetSopNodeID sets the "sop_node" edge to the SopNode entity by ID.
- func (mruo *MessageRecordsUpdateOne) SetSopNodeID(id uint64) *MessageRecordsUpdateOne {
- mruo.mutation.SetSopNodeID(id)
- return mruo
- }
- // SetNillableSopNodeID sets the "sop_node" edge to the SopNode entity by ID if the given value is not nil.
- func (mruo *MessageRecordsUpdateOne) SetNillableSopNodeID(id *uint64) *MessageRecordsUpdateOne {
- if id != nil {
- mruo = mruo.SetSopNodeID(*id)
- }
- return mruo
- }
- // SetSopNode sets the "sop_node" edge to the SopNode entity.
- func (mruo *MessageRecordsUpdateOne) SetSopNode(s *SopNode) *MessageRecordsUpdateOne {
- return mruo.SetSopNodeID(s.ID)
- }
- // SetMessageContactID sets the "message_contact" edge to the Contact entity by ID.
- func (mruo *MessageRecordsUpdateOne) SetMessageContactID(id uint64) *MessageRecordsUpdateOne {
- mruo.mutation.SetMessageContactID(id)
- return mruo
- }
- // SetNillableMessageContactID sets the "message_contact" edge to the Contact entity by ID if the given value is not nil.
- func (mruo *MessageRecordsUpdateOne) SetNillableMessageContactID(id *uint64) *MessageRecordsUpdateOne {
- if id != nil {
- mruo = mruo.SetMessageContactID(*id)
- }
- return mruo
- }
- // SetMessageContact sets the "message_contact" edge to the Contact entity.
- func (mruo *MessageRecordsUpdateOne) SetMessageContact(c *Contact) *MessageRecordsUpdateOne {
- return mruo.SetMessageContactID(c.ID)
- }
- // Mutation returns the MessageRecordsMutation object of the builder.
- func (mruo *MessageRecordsUpdateOne) Mutation() *MessageRecordsMutation {
- return mruo.mutation
- }
- // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
- func (mruo *MessageRecordsUpdateOne) ClearSopStage() *MessageRecordsUpdateOne {
- mruo.mutation.ClearSopStage()
- return mruo
- }
- // ClearSopNode clears the "sop_node" edge to the SopNode entity.
- func (mruo *MessageRecordsUpdateOne) ClearSopNode() *MessageRecordsUpdateOne {
- mruo.mutation.ClearSopNode()
- return mruo
- }
- // ClearMessageContact clears the "message_contact" edge to the Contact entity.
- func (mruo *MessageRecordsUpdateOne) ClearMessageContact() *MessageRecordsUpdateOne {
- mruo.mutation.ClearMessageContact()
- return mruo
- }
- // Where appends a list predicates to the MessageRecordsUpdate builder.
- func (mruo *MessageRecordsUpdateOne) Where(ps ...predicate.MessageRecords) *MessageRecordsUpdateOne {
- mruo.mutation.Where(ps...)
- return mruo
- }
- // Select allows selecting one or more fields (columns) of the returned entity.
- // The default is selecting all fields defined in the entity schema.
- func (mruo *MessageRecordsUpdateOne) Select(field string, fields ...string) *MessageRecordsUpdateOne {
- mruo.fields = append([]string{field}, fields...)
- return mruo
- }
- // Save executes the query and returns the updated MessageRecords entity.
- func (mruo *MessageRecordsUpdateOne) Save(ctx context.Context) (*MessageRecords, error) {
- mruo.defaults()
- return withHooks(ctx, mruo.sqlSave, mruo.mutation, mruo.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (mruo *MessageRecordsUpdateOne) SaveX(ctx context.Context) *MessageRecords {
- node, err := mruo.Save(ctx)
- if err != nil {
- panic(err)
- }
- return node
- }
- // Exec executes the query on the entity.
- func (mruo *MessageRecordsUpdateOne) Exec(ctx context.Context) error {
- _, err := mruo.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (mruo *MessageRecordsUpdateOne) ExecX(ctx context.Context) {
- if err := mruo.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (mruo *MessageRecordsUpdateOne) defaults() {
- if _, ok := mruo.mutation.UpdatedAt(); !ok {
- v := messagerecords.UpdateDefaultUpdatedAt()
- mruo.mutation.SetUpdatedAt(v)
- }
- }
- func (mruo *MessageRecordsUpdateOne) sqlSave(ctx context.Context) (_node *MessageRecords, err error) {
- _spec := sqlgraph.NewUpdateSpec(messagerecords.Table, messagerecords.Columns, sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64))
- id, ok := mruo.mutation.ID()
- if !ok {
- return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "MessageRecords.id" for update`)}
- }
- _spec.Node.ID.Value = id
- if fields := mruo.fields; len(fields) > 0 {
- _spec.Node.Columns = make([]string, 0, len(fields))
- _spec.Node.Columns = append(_spec.Node.Columns, messagerecords.FieldID)
- for _, f := range fields {
- if !messagerecords.ValidColumn(f) {
- return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
- }
- if f != messagerecords.FieldID {
- _spec.Node.Columns = append(_spec.Node.Columns, f)
- }
- }
- }
- if ps := mruo.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := mruo.mutation.UpdatedAt(); ok {
- _spec.SetField(messagerecords.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := mruo.mutation.Status(); ok {
- _spec.SetField(messagerecords.FieldStatus, field.TypeUint8, value)
- }
- if value, ok := mruo.mutation.AddedStatus(); ok {
- _spec.AddField(messagerecords.FieldStatus, field.TypeUint8, value)
- }
- if mruo.mutation.StatusCleared() {
- _spec.ClearField(messagerecords.FieldStatus, field.TypeUint8)
- }
- if value, ok := mruo.mutation.BotWxid(); ok {
- _spec.SetField(messagerecords.FieldBotWxid, field.TypeString, value)
- }
- if value, ok := mruo.mutation.ContactType(); ok {
- _spec.SetField(messagerecords.FieldContactType, field.TypeInt, value)
- }
- if value, ok := mruo.mutation.AddedContactType(); ok {
- _spec.AddField(messagerecords.FieldContactType, field.TypeInt, value)
- }
- if value, ok := mruo.mutation.ContactWxid(); ok {
- _spec.SetField(messagerecords.FieldContactWxid, field.TypeString, value)
- }
- if value, ok := mruo.mutation.ContentType(); ok {
- _spec.SetField(messagerecords.FieldContentType, field.TypeInt, value)
- }
- if value, ok := mruo.mutation.AddedContentType(); ok {
- _spec.AddField(messagerecords.FieldContentType, field.TypeInt, value)
- }
- if value, ok := mruo.mutation.Content(); ok {
- _spec.SetField(messagerecords.FieldContent, field.TypeString, value)
- }
- if value, ok := mruo.mutation.Meta(); ok {
- _spec.SetField(messagerecords.FieldMeta, field.TypeJSON, value)
- }
- if mruo.mutation.MetaCleared() {
- _spec.ClearField(messagerecords.FieldMeta, field.TypeJSON)
- }
- if value, ok := mruo.mutation.ErrorDetail(); ok {
- _spec.SetField(messagerecords.FieldErrorDetail, field.TypeString, value)
- }
- if value, ok := mruo.mutation.SendTime(); ok {
- _spec.SetField(messagerecords.FieldSendTime, field.TypeTime, value)
- }
- if mruo.mutation.SendTimeCleared() {
- _spec.ClearField(messagerecords.FieldSendTime, field.TypeTime)
- }
- if value, ok := mruo.mutation.SourceType(); ok {
- _spec.SetField(messagerecords.FieldSourceType, field.TypeInt, value)
- }
- if value, ok := mruo.mutation.AddedSourceType(); ok {
- _spec.AddField(messagerecords.FieldSourceType, field.TypeInt, value)
- }
- if value, ok := mruo.mutation.OrganizationID(); ok {
- _spec.SetField(messagerecords.FieldOrganizationID, field.TypeUint64, value)
- }
- if value, ok := mruo.mutation.AddedOrganizationID(); ok {
- _spec.AddField(messagerecords.FieldOrganizationID, field.TypeUint64, value)
- }
- if mruo.mutation.OrganizationIDCleared() {
- _spec.ClearField(messagerecords.FieldOrganizationID, field.TypeUint64)
- }
- if mruo.mutation.SopStageCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: messagerecords.SopStageTable,
- Columns: []string{messagerecords.SopStageColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopstage.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := mruo.mutation.SopStageIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: messagerecords.SopStageTable,
- Columns: []string{messagerecords.SopStageColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopstage.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if mruo.mutation.SopNodeCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: messagerecords.SopNodeTable,
- Columns: []string{messagerecords.SopNodeColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := mruo.mutation.SopNodeIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: messagerecords.SopNodeTable,
- Columns: []string{messagerecords.SopNodeColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if mruo.mutation.MessageContactCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: messagerecords.MessageContactTable,
- Columns: []string{messagerecords.MessageContactColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := mruo.mutation.MessageContactIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: messagerecords.MessageContactTable,
- Columns: []string{messagerecords.MessageContactColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- _node = &MessageRecords{config: mruo.config}
- _spec.Assign = _node.assignValues
- _spec.ScanValues = _node.scanValues
- if err = sqlgraph.UpdateNode(ctx, mruo.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{messagerecords.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- mruo.mutation.done = true
- return _node, nil
- }
|