|
@@ -0,0 +1,1547 @@
|
|
|
+// Code generated by ent, DO NOT EDIT.
|
|
|
+
|
|
|
+package ent
|
|
|
+
|
|
|
+import (
|
|
|
+ "context"
|
|
|
+ "errors"
|
|
|
+ "fmt"
|
|
|
+ "time"
|
|
|
+ "wechat-api/ent/messagerecords"
|
|
|
+
|
|
|
+ "entgo.io/ent/dialect/sql"
|
|
|
+ "entgo.io/ent/dialect/sql/sqlgraph"
|
|
|
+ "entgo.io/ent/schema/field"
|
|
|
+)
|
|
|
+
|
|
|
+// MessageRecordsCreate is the builder for creating a MessageRecords entity.
|
|
|
+type MessageRecordsCreate struct {
|
|
|
+ config
|
|
|
+ mutation *MessageRecordsMutation
|
|
|
+ hooks []Hook
|
|
|
+ conflict []sql.ConflictOption
|
|
|
+}
|
|
|
+
|
|
|
+// SetCreatedAt sets the "created_at" field.
|
|
|
+func (mrc *MessageRecordsCreate) SetCreatedAt(t time.Time) *MessageRecordsCreate {
|
|
|
+ mrc.mutation.SetCreatedAt(t)
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
|
+func (mrc *MessageRecordsCreate) SetNillableCreatedAt(t *time.Time) *MessageRecordsCreate {
|
|
|
+ if t != nil {
|
|
|
+ mrc.SetCreatedAt(*t)
|
|
|
+ }
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetUpdatedAt sets the "updated_at" field.
|
|
|
+func (mrc *MessageRecordsCreate) SetUpdatedAt(t time.Time) *MessageRecordsCreate {
|
|
|
+ mrc.mutation.SetUpdatedAt(t)
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
|
+func (mrc *MessageRecordsCreate) SetNillableUpdatedAt(t *time.Time) *MessageRecordsCreate {
|
|
|
+ if t != nil {
|
|
|
+ mrc.SetUpdatedAt(*t)
|
|
|
+ }
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetStatus sets the "status" field.
|
|
|
+func (mrc *MessageRecordsCreate) SetStatus(u uint8) *MessageRecordsCreate {
|
|
|
+ mrc.mutation.SetStatus(u)
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
|
+func (mrc *MessageRecordsCreate) SetNillableStatus(u *uint8) *MessageRecordsCreate {
|
|
|
+ if u != nil {
|
|
|
+ mrc.SetStatus(*u)
|
|
|
+ }
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetDeletedAt sets the "deleted_at" field.
|
|
|
+func (mrc *MessageRecordsCreate) SetDeletedAt(t time.Time) *MessageRecordsCreate {
|
|
|
+ mrc.mutation.SetDeletedAt(t)
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
|
+func (mrc *MessageRecordsCreate) SetNillableDeletedAt(t *time.Time) *MessageRecordsCreate {
|
|
|
+ if t != nil {
|
|
|
+ mrc.SetDeletedAt(*t)
|
|
|
+ }
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetBotWxid sets the "bot_wxid" field.
|
|
|
+func (mrc *MessageRecordsCreate) SetBotWxid(s string) *MessageRecordsCreate {
|
|
|
+ mrc.mutation.SetBotWxid(s)
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetContactID sets the "contact_id" field.
|
|
|
+func (mrc *MessageRecordsCreate) SetContactID(i int) *MessageRecordsCreate {
|
|
|
+ mrc.mutation.SetContactID(i)
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetContactType sets the "contact_type" field.
|
|
|
+func (mrc *MessageRecordsCreate) SetContactType(i int) *MessageRecordsCreate {
|
|
|
+ mrc.mutation.SetContactType(i)
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableContactType sets the "contact_type" field if the given value is not nil.
|
|
|
+func (mrc *MessageRecordsCreate) SetNillableContactType(i *int) *MessageRecordsCreate {
|
|
|
+ if i != nil {
|
|
|
+ mrc.SetContactType(*i)
|
|
|
+ }
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetContactWxid sets the "contact_wxid" field.
|
|
|
+func (mrc *MessageRecordsCreate) SetContactWxid(s string) *MessageRecordsCreate {
|
|
|
+ mrc.mutation.SetContactWxid(s)
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableContactWxid sets the "contact_wxid" field if the given value is not nil.
|
|
|
+func (mrc *MessageRecordsCreate) SetNillableContactWxid(s *string) *MessageRecordsCreate {
|
|
|
+ if s != nil {
|
|
|
+ mrc.SetContactWxid(*s)
|
|
|
+ }
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetContentType sets the "content_type" field.
|
|
|
+func (mrc *MessageRecordsCreate) SetContentType(i int) *MessageRecordsCreate {
|
|
|
+ mrc.mutation.SetContentType(i)
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableContentType sets the "content_type" field if the given value is not nil.
|
|
|
+func (mrc *MessageRecordsCreate) SetNillableContentType(i *int) *MessageRecordsCreate {
|
|
|
+ if i != nil {
|
|
|
+ mrc.SetContentType(*i)
|
|
|
+ }
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetContent sets the "content" field.
|
|
|
+func (mrc *MessageRecordsCreate) SetContent(s string) *MessageRecordsCreate {
|
|
|
+ mrc.mutation.SetContent(s)
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableContent sets the "content" field if the given value is not nil.
|
|
|
+func (mrc *MessageRecordsCreate) SetNillableContent(s *string) *MessageRecordsCreate {
|
|
|
+ if s != nil {
|
|
|
+ mrc.SetContent(*s)
|
|
|
+ }
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetErrorDetail sets the "error_detail" field.
|
|
|
+func (mrc *MessageRecordsCreate) SetErrorDetail(s string) *MessageRecordsCreate {
|
|
|
+ mrc.mutation.SetErrorDetail(s)
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableErrorDetail sets the "error_detail" field if the given value is not nil.
|
|
|
+func (mrc *MessageRecordsCreate) SetNillableErrorDetail(s *string) *MessageRecordsCreate {
|
|
|
+ if s != nil {
|
|
|
+ mrc.SetErrorDetail(*s)
|
|
|
+ }
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetSendTime sets the "send_time" field.
|
|
|
+func (mrc *MessageRecordsCreate) SetSendTime(t time.Time) *MessageRecordsCreate {
|
|
|
+ mrc.mutation.SetSendTime(t)
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableSendTime sets the "send_time" field if the given value is not nil.
|
|
|
+func (mrc *MessageRecordsCreate) SetNillableSendTime(t *time.Time) *MessageRecordsCreate {
|
|
|
+ if t != nil {
|
|
|
+ mrc.SetSendTime(*t)
|
|
|
+ }
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetSourceType sets the "source_type" field.
|
|
|
+func (mrc *MessageRecordsCreate) SetSourceType(i int) *MessageRecordsCreate {
|
|
|
+ mrc.mutation.SetSourceType(i)
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableSourceType sets the "source_type" field if the given value is not nil.
|
|
|
+func (mrc *MessageRecordsCreate) SetNillableSourceType(i *int) *MessageRecordsCreate {
|
|
|
+ if i != nil {
|
|
|
+ mrc.SetSourceType(*i)
|
|
|
+ }
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetSourceID sets the "source_id" field.
|
|
|
+func (mrc *MessageRecordsCreate) SetSourceID(i int) *MessageRecordsCreate {
|
|
|
+ mrc.mutation.SetSourceID(i)
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableSourceID sets the "source_id" field if the given value is not nil.
|
|
|
+func (mrc *MessageRecordsCreate) SetNillableSourceID(i *int) *MessageRecordsCreate {
|
|
|
+ if i != nil {
|
|
|
+ mrc.SetSourceID(*i)
|
|
|
+ }
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetSubSourceID sets the "sub_source_id" field.
|
|
|
+func (mrc *MessageRecordsCreate) SetSubSourceID(i int) *MessageRecordsCreate {
|
|
|
+ mrc.mutation.SetSubSourceID(i)
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableSubSourceID sets the "sub_source_id" field if the given value is not nil.
|
|
|
+func (mrc *MessageRecordsCreate) SetNillableSubSourceID(i *int) *MessageRecordsCreate {
|
|
|
+ if i != nil {
|
|
|
+ mrc.SetSubSourceID(*i)
|
|
|
+ }
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// SetID sets the "id" field.
|
|
|
+func (mrc *MessageRecordsCreate) SetID(u uint64) *MessageRecordsCreate {
|
|
|
+ mrc.mutation.SetID(u)
|
|
|
+ return mrc
|
|
|
+}
|
|
|
+
|
|
|
+// Mutation returns the MessageRecordsMutation object of the builder.
|
|
|
+func (mrc *MessageRecordsCreate) Mutation() *MessageRecordsMutation {
|
|
|
+ return mrc.mutation
|
|
|
+}
|
|
|
+
|
|
|
+// Save creates the MessageRecords in the database.
|
|
|
+func (mrc *MessageRecordsCreate) Save(ctx context.Context) (*MessageRecords, error) {
|
|
|
+ if err := mrc.defaults(); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ return withHooks(ctx, mrc.sqlSave, mrc.mutation, mrc.hooks)
|
|
|
+}
|
|
|
+
|
|
|
+// SaveX calls Save and panics if Save returns an error.
|
|
|
+func (mrc *MessageRecordsCreate) SaveX(ctx context.Context) *MessageRecords {
|
|
|
+ v, err := mrc.Save(ctx)
|
|
|
+ if err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+ return v
|
|
|
+}
|
|
|
+
|
|
|
+// Exec executes the query.
|
|
|
+func (mrc *MessageRecordsCreate) Exec(ctx context.Context) error {
|
|
|
+ _, err := mrc.Save(ctx)
|
|
|
+ return err
|
|
|
+}
|
|
|
+
|
|
|
+// ExecX is like Exec, but panics if an error occurs.
|
|
|
+func (mrc *MessageRecordsCreate) ExecX(ctx context.Context) {
|
|
|
+ if err := mrc.Exec(ctx); err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// defaults sets the default values of the builder before save.
|
|
|
+func (mrc *MessageRecordsCreate) defaults() error {
|
|
|
+ if _, ok := mrc.mutation.CreatedAt(); !ok {
|
|
|
+ if messagerecords.DefaultCreatedAt == nil {
|
|
|
+ return fmt.Errorf("ent: uninitialized messagerecords.DefaultCreatedAt (forgotten import ent/runtime?)")
|
|
|
+ }
|
|
|
+ v := messagerecords.DefaultCreatedAt()
|
|
|
+ mrc.mutation.SetCreatedAt(v)
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.UpdatedAt(); !ok {
|
|
|
+ if messagerecords.DefaultUpdatedAt == nil {
|
|
|
+ return fmt.Errorf("ent: uninitialized messagerecords.DefaultUpdatedAt (forgotten import ent/runtime?)")
|
|
|
+ }
|
|
|
+ v := messagerecords.DefaultUpdatedAt()
|
|
|
+ mrc.mutation.SetUpdatedAt(v)
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.Status(); !ok {
|
|
|
+ v := messagerecords.DefaultStatus
|
|
|
+ mrc.mutation.SetStatus(v)
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.ContactType(); !ok {
|
|
|
+ v := messagerecords.DefaultContactType
|
|
|
+ mrc.mutation.SetContactType(v)
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.ContactWxid(); !ok {
|
|
|
+ v := messagerecords.DefaultContactWxid
|
|
|
+ mrc.mutation.SetContactWxid(v)
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.ContentType(); !ok {
|
|
|
+ v := messagerecords.DefaultContentType
|
|
|
+ mrc.mutation.SetContentType(v)
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.Content(); !ok {
|
|
|
+ v := messagerecords.DefaultContent
|
|
|
+ mrc.mutation.SetContent(v)
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.ErrorDetail(); !ok {
|
|
|
+ v := messagerecords.DefaultErrorDetail
|
|
|
+ mrc.mutation.SetErrorDetail(v)
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.SourceType(); !ok {
|
|
|
+ v := messagerecords.DefaultSourceType
|
|
|
+ mrc.mutation.SetSourceType(v)
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.SourceID(); !ok {
|
|
|
+ v := messagerecords.DefaultSourceID
|
|
|
+ mrc.mutation.SetSourceID(v)
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.SubSourceID(); !ok {
|
|
|
+ v := messagerecords.DefaultSubSourceID
|
|
|
+ mrc.mutation.SetSubSourceID(v)
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// check runs all checks and user-defined validators on the builder.
|
|
|
+func (mrc *MessageRecordsCreate) check() error {
|
|
|
+ if _, ok := mrc.mutation.CreatedAt(); !ok {
|
|
|
+ return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "MessageRecords.created_at"`)}
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.UpdatedAt(); !ok {
|
|
|
+ return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "MessageRecords.updated_at"`)}
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.BotWxid(); !ok {
|
|
|
+ return &ValidationError{Name: "bot_wxid", err: errors.New(`ent: missing required field "MessageRecords.bot_wxid"`)}
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.ContactID(); !ok {
|
|
|
+ return &ValidationError{Name: "contact_id", err: errors.New(`ent: missing required field "MessageRecords.contact_id"`)}
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.ContactType(); !ok {
|
|
|
+ return &ValidationError{Name: "contact_type", err: errors.New(`ent: missing required field "MessageRecords.contact_type"`)}
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.ContactWxid(); !ok {
|
|
|
+ return &ValidationError{Name: "contact_wxid", err: errors.New(`ent: missing required field "MessageRecords.contact_wxid"`)}
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.ContentType(); !ok {
|
|
|
+ return &ValidationError{Name: "content_type", err: errors.New(`ent: missing required field "MessageRecords.content_type"`)}
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.Content(); !ok {
|
|
|
+ return &ValidationError{Name: "content", err: errors.New(`ent: missing required field "MessageRecords.content"`)}
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.ErrorDetail(); !ok {
|
|
|
+ return &ValidationError{Name: "error_detail", err: errors.New(`ent: missing required field "MessageRecords.error_detail"`)}
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.SourceType(); !ok {
|
|
|
+ return &ValidationError{Name: "source_type", err: errors.New(`ent: missing required field "MessageRecords.source_type"`)}
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.SourceID(); !ok {
|
|
|
+ return &ValidationError{Name: "source_id", err: errors.New(`ent: missing required field "MessageRecords.source_id"`)}
|
|
|
+ }
|
|
|
+ if _, ok := mrc.mutation.SubSourceID(); !ok {
|
|
|
+ return &ValidationError{Name: "sub_source_id", err: errors.New(`ent: missing required field "MessageRecords.sub_source_id"`)}
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+func (mrc *MessageRecordsCreate) sqlSave(ctx context.Context) (*MessageRecords, error) {
|
|
|
+ if err := mrc.check(); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ _node, _spec := mrc.createSpec()
|
|
|
+ if err := sqlgraph.CreateNode(ctx, mrc.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)
|
|
|
+ }
|
|
|
+ mrc.mutation.id = &_node.ID
|
|
|
+ mrc.mutation.done = true
|
|
|
+ return _node, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (mrc *MessageRecordsCreate) createSpec() (*MessageRecords, *sqlgraph.CreateSpec) {
|
|
|
+ var (
|
|
|
+ _node = &MessageRecords{config: mrc.config}
|
|
|
+ _spec = sqlgraph.NewCreateSpec(messagerecords.Table, sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64))
|
|
|
+ )
|
|
|
+ _spec.OnConflict = mrc.conflict
|
|
|
+ if id, ok := mrc.mutation.ID(); ok {
|
|
|
+ _node.ID = id
|
|
|
+ _spec.ID.Value = id
|
|
|
+ }
|
|
|
+ if value, ok := mrc.mutation.CreatedAt(); ok {
|
|
|
+ _spec.SetField(messagerecords.FieldCreatedAt, field.TypeTime, value)
|
|
|
+ _node.CreatedAt = value
|
|
|
+ }
|
|
|
+ if value, ok := mrc.mutation.UpdatedAt(); ok {
|
|
|
+ _spec.SetField(messagerecords.FieldUpdatedAt, field.TypeTime, value)
|
|
|
+ _node.UpdatedAt = value
|
|
|
+ }
|
|
|
+ if value, ok := mrc.mutation.Status(); ok {
|
|
|
+ _spec.SetField(messagerecords.FieldStatus, field.TypeUint8, value)
|
|
|
+ _node.Status = value
|
|
|
+ }
|
|
|
+ if value, ok := mrc.mutation.DeletedAt(); ok {
|
|
|
+ _spec.SetField(messagerecords.FieldDeletedAt, field.TypeTime, value)
|
|
|
+ _node.DeletedAt = value
|
|
|
+ }
|
|
|
+ if value, ok := mrc.mutation.BotWxid(); ok {
|
|
|
+ _spec.SetField(messagerecords.FieldBotWxid, field.TypeString, value)
|
|
|
+ _node.BotWxid = value
|
|
|
+ }
|
|
|
+ if value, ok := mrc.mutation.ContactID(); ok {
|
|
|
+ _spec.SetField(messagerecords.FieldContactID, field.TypeInt, value)
|
|
|
+ _node.ContactID = value
|
|
|
+ }
|
|
|
+ if value, ok := mrc.mutation.ContactType(); ok {
|
|
|
+ _spec.SetField(messagerecords.FieldContactType, field.TypeInt, value)
|
|
|
+ _node.ContactType = value
|
|
|
+ }
|
|
|
+ if value, ok := mrc.mutation.ContactWxid(); ok {
|
|
|
+ _spec.SetField(messagerecords.FieldContactWxid, field.TypeString, value)
|
|
|
+ _node.ContactWxid = value
|
|
|
+ }
|
|
|
+ if value, ok := mrc.mutation.ContentType(); ok {
|
|
|
+ _spec.SetField(messagerecords.FieldContentType, field.TypeInt, value)
|
|
|
+ _node.ContentType = value
|
|
|
+ }
|
|
|
+ if value, ok := mrc.mutation.Content(); ok {
|
|
|
+ _spec.SetField(messagerecords.FieldContent, field.TypeString, value)
|
|
|
+ _node.Content = value
|
|
|
+ }
|
|
|
+ if value, ok := mrc.mutation.ErrorDetail(); ok {
|
|
|
+ _spec.SetField(messagerecords.FieldErrorDetail, field.TypeString, value)
|
|
|
+ _node.ErrorDetail = value
|
|
|
+ }
|
|
|
+ if value, ok := mrc.mutation.SendTime(); ok {
|
|
|
+ _spec.SetField(messagerecords.FieldSendTime, field.TypeTime, value)
|
|
|
+ _node.SendTime = value
|
|
|
+ }
|
|
|
+ if value, ok := mrc.mutation.SourceType(); ok {
|
|
|
+ _spec.SetField(messagerecords.FieldSourceType, field.TypeInt, value)
|
|
|
+ _node.SourceType = value
|
|
|
+ }
|
|
|
+ if value, ok := mrc.mutation.SourceID(); ok {
|
|
|
+ _spec.SetField(messagerecords.FieldSourceID, field.TypeInt, value)
|
|
|
+ _node.SourceID = value
|
|
|
+ }
|
|
|
+ if value, ok := mrc.mutation.SubSourceID(); ok {
|
|
|
+ _spec.SetField(messagerecords.FieldSubSourceID, field.TypeInt, value)
|
|
|
+ _node.SubSourceID = value
|
|
|
+ }
|
|
|
+ return _node, _spec
|
|
|
+}
|
|
|
+
|
|
|
+// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
|
+// of the `INSERT` statement. For example:
|
|
|
+//
|
|
|
+// client.MessageRecords.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.MessageRecordsUpsert) {
|
|
|
+// SetCreatedAt(v+v).
|
|
|
+// }).
|
|
|
+// Exec(ctx)
|
|
|
+func (mrc *MessageRecordsCreate) OnConflict(opts ...sql.ConflictOption) *MessageRecordsUpsertOne {
|
|
|
+ mrc.conflict = opts
|
|
|
+ return &MessageRecordsUpsertOne{
|
|
|
+ create: mrc,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// OnConflictColumns calls `OnConflict` and configures the columns
|
|
|
+// as conflict target. Using this option is equivalent to using:
|
|
|
+//
|
|
|
+// client.MessageRecords.Create().
|
|
|
+// OnConflict(sql.ConflictColumns(columns...)).
|
|
|
+// Exec(ctx)
|
|
|
+func (mrc *MessageRecordsCreate) OnConflictColumns(columns ...string) *MessageRecordsUpsertOne {
|
|
|
+ mrc.conflict = append(mrc.conflict, sql.ConflictColumns(columns...))
|
|
|
+ return &MessageRecordsUpsertOne{
|
|
|
+ create: mrc,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+type (
|
|
|
+ // MessageRecordsUpsertOne is the builder for "upsert"-ing
|
|
|
+ // one MessageRecords node.
|
|
|
+ MessageRecordsUpsertOne struct {
|
|
|
+ create *MessageRecordsCreate
|
|
|
+ }
|
|
|
+
|
|
|
+ // MessageRecordsUpsert is the "OnConflict" setter.
|
|
|
+ MessageRecordsUpsert struct {
|
|
|
+ *sql.UpdateSet
|
|
|
+ }
|
|
|
+)
|
|
|
+
|
|
|
+// SetUpdatedAt sets the "updated_at" field.
|
|
|
+func (u *MessageRecordsUpsert) SetUpdatedAt(v time.Time) *MessageRecordsUpsert {
|
|
|
+ u.Set(messagerecords.FieldUpdatedAt, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsert) UpdateUpdatedAt() *MessageRecordsUpsert {
|
|
|
+ u.SetExcluded(messagerecords.FieldUpdatedAt)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetStatus sets the "status" field.
|
|
|
+func (u *MessageRecordsUpsert) SetStatus(v uint8) *MessageRecordsUpsert {
|
|
|
+ u.Set(messagerecords.FieldStatus, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsert) UpdateStatus() *MessageRecordsUpsert {
|
|
|
+ u.SetExcluded(messagerecords.FieldStatus)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// AddStatus adds v to the "status" field.
|
|
|
+func (u *MessageRecordsUpsert) AddStatus(v uint8) *MessageRecordsUpsert {
|
|
|
+ u.Add(messagerecords.FieldStatus, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// ClearStatus clears the value of the "status" field.
|
|
|
+func (u *MessageRecordsUpsert) ClearStatus() *MessageRecordsUpsert {
|
|
|
+ u.SetNull(messagerecords.FieldStatus)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetDeletedAt sets the "deleted_at" field.
|
|
|
+func (u *MessageRecordsUpsert) SetDeletedAt(v time.Time) *MessageRecordsUpsert {
|
|
|
+ u.Set(messagerecords.FieldDeletedAt, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsert) UpdateDeletedAt() *MessageRecordsUpsert {
|
|
|
+ u.SetExcluded(messagerecords.FieldDeletedAt)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
|
+func (u *MessageRecordsUpsert) ClearDeletedAt() *MessageRecordsUpsert {
|
|
|
+ u.SetNull(messagerecords.FieldDeletedAt)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetBotWxid sets the "bot_wxid" field.
|
|
|
+func (u *MessageRecordsUpsert) SetBotWxid(v string) *MessageRecordsUpsert {
|
|
|
+ u.Set(messagerecords.FieldBotWxid, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateBotWxid sets the "bot_wxid" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsert) UpdateBotWxid() *MessageRecordsUpsert {
|
|
|
+ u.SetExcluded(messagerecords.FieldBotWxid)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetContactID sets the "contact_id" field.
|
|
|
+func (u *MessageRecordsUpsert) SetContactID(v int) *MessageRecordsUpsert {
|
|
|
+ u.Set(messagerecords.FieldContactID, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateContactID sets the "contact_id" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsert) UpdateContactID() *MessageRecordsUpsert {
|
|
|
+ u.SetExcluded(messagerecords.FieldContactID)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// AddContactID adds v to the "contact_id" field.
|
|
|
+func (u *MessageRecordsUpsert) AddContactID(v int) *MessageRecordsUpsert {
|
|
|
+ u.Add(messagerecords.FieldContactID, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetContactType sets the "contact_type" field.
|
|
|
+func (u *MessageRecordsUpsert) SetContactType(v int) *MessageRecordsUpsert {
|
|
|
+ u.Set(messagerecords.FieldContactType, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateContactType sets the "contact_type" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsert) UpdateContactType() *MessageRecordsUpsert {
|
|
|
+ u.SetExcluded(messagerecords.FieldContactType)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// AddContactType adds v to the "contact_type" field.
|
|
|
+func (u *MessageRecordsUpsert) AddContactType(v int) *MessageRecordsUpsert {
|
|
|
+ u.Add(messagerecords.FieldContactType, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetContactWxid sets the "contact_wxid" field.
|
|
|
+func (u *MessageRecordsUpsert) SetContactWxid(v string) *MessageRecordsUpsert {
|
|
|
+ u.Set(messagerecords.FieldContactWxid, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateContactWxid sets the "contact_wxid" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsert) UpdateContactWxid() *MessageRecordsUpsert {
|
|
|
+ u.SetExcluded(messagerecords.FieldContactWxid)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetContentType sets the "content_type" field.
|
|
|
+func (u *MessageRecordsUpsert) SetContentType(v int) *MessageRecordsUpsert {
|
|
|
+ u.Set(messagerecords.FieldContentType, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateContentType sets the "content_type" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsert) UpdateContentType() *MessageRecordsUpsert {
|
|
|
+ u.SetExcluded(messagerecords.FieldContentType)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// AddContentType adds v to the "content_type" field.
|
|
|
+func (u *MessageRecordsUpsert) AddContentType(v int) *MessageRecordsUpsert {
|
|
|
+ u.Add(messagerecords.FieldContentType, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetContent sets the "content" field.
|
|
|
+func (u *MessageRecordsUpsert) SetContent(v string) *MessageRecordsUpsert {
|
|
|
+ u.Set(messagerecords.FieldContent, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateContent sets the "content" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsert) UpdateContent() *MessageRecordsUpsert {
|
|
|
+ u.SetExcluded(messagerecords.FieldContent)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetErrorDetail sets the "error_detail" field.
|
|
|
+func (u *MessageRecordsUpsert) SetErrorDetail(v string) *MessageRecordsUpsert {
|
|
|
+ u.Set(messagerecords.FieldErrorDetail, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateErrorDetail sets the "error_detail" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsert) UpdateErrorDetail() *MessageRecordsUpsert {
|
|
|
+ u.SetExcluded(messagerecords.FieldErrorDetail)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetSendTime sets the "send_time" field.
|
|
|
+func (u *MessageRecordsUpsert) SetSendTime(v time.Time) *MessageRecordsUpsert {
|
|
|
+ u.Set(messagerecords.FieldSendTime, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateSendTime sets the "send_time" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsert) UpdateSendTime() *MessageRecordsUpsert {
|
|
|
+ u.SetExcluded(messagerecords.FieldSendTime)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// ClearSendTime clears the value of the "send_time" field.
|
|
|
+func (u *MessageRecordsUpsert) ClearSendTime() *MessageRecordsUpsert {
|
|
|
+ u.SetNull(messagerecords.FieldSendTime)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetSourceType sets the "source_type" field.
|
|
|
+func (u *MessageRecordsUpsert) SetSourceType(v int) *MessageRecordsUpsert {
|
|
|
+ u.Set(messagerecords.FieldSourceType, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateSourceType sets the "source_type" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsert) UpdateSourceType() *MessageRecordsUpsert {
|
|
|
+ u.SetExcluded(messagerecords.FieldSourceType)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// AddSourceType adds v to the "source_type" field.
|
|
|
+func (u *MessageRecordsUpsert) AddSourceType(v int) *MessageRecordsUpsert {
|
|
|
+ u.Add(messagerecords.FieldSourceType, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetSourceID sets the "source_id" field.
|
|
|
+func (u *MessageRecordsUpsert) SetSourceID(v int) *MessageRecordsUpsert {
|
|
|
+ u.Set(messagerecords.FieldSourceID, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateSourceID sets the "source_id" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsert) UpdateSourceID() *MessageRecordsUpsert {
|
|
|
+ u.SetExcluded(messagerecords.FieldSourceID)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// AddSourceID adds v to the "source_id" field.
|
|
|
+func (u *MessageRecordsUpsert) AddSourceID(v int) *MessageRecordsUpsert {
|
|
|
+ u.Add(messagerecords.FieldSourceID, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetSubSourceID sets the "sub_source_id" field.
|
|
|
+func (u *MessageRecordsUpsert) SetSubSourceID(v int) *MessageRecordsUpsert {
|
|
|
+ u.Set(messagerecords.FieldSubSourceID, v)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateSubSourceID sets the "sub_source_id" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsert) UpdateSubSourceID() *MessageRecordsUpsert {
|
|
|
+ u.SetExcluded(messagerecords.FieldSubSourceID)
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// AddSubSourceID adds v to the "sub_source_id" field.
|
|
|
+func (u *MessageRecordsUpsert) AddSubSourceID(v int) *MessageRecordsUpsert {
|
|
|
+ u.Add(messagerecords.FieldSubSourceID, v)
|
|
|
+ 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.MessageRecords.Create().
|
|
|
+// OnConflict(
|
|
|
+// sql.ResolveWithNewValues(),
|
|
|
+// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
|
+// u.SetIgnore(messagerecords.FieldID)
|
|
|
+// }),
|
|
|
+// ).
|
|
|
+// Exec(ctx)
|
|
|
+func (u *MessageRecordsUpsertOne) UpdateNewValues() *MessageRecordsUpsertOne {
|
|
|
+ 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(messagerecords.FieldID)
|
|
|
+ }
|
|
|
+ if _, exists := u.create.mutation.CreatedAt(); exists {
|
|
|
+ s.SetIgnore(messagerecords.FieldCreatedAt)
|
|
|
+ }
|
|
|
+ }))
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// Ignore sets each column to itself in case of conflict.
|
|
|
+// Using this option is equivalent to using:
|
|
|
+//
|
|
|
+// client.MessageRecords.Create().
|
|
|
+// OnConflict(sql.ResolveWithIgnore()).
|
|
|
+// Exec(ctx)
|
|
|
+func (u *MessageRecordsUpsertOne) Ignore() *MessageRecordsUpsertOne {
|
|
|
+ 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 *MessageRecordsUpsertOne) DoNothing() *MessageRecordsUpsertOne {
|
|
|
+ u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// Update allows overriding fields `UPDATE` values. See the MessageRecordsCreate.OnConflict
|
|
|
+// documentation for more info.
|
|
|
+func (u *MessageRecordsUpsertOne) Update(set func(*MessageRecordsUpsert)) *MessageRecordsUpsertOne {
|
|
|
+ u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
|
+ set(&MessageRecordsUpsert{UpdateSet: update})
|
|
|
+ }))
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetUpdatedAt sets the "updated_at" field.
|
|
|
+func (u *MessageRecordsUpsertOne) SetUpdatedAt(v time.Time) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetUpdatedAt(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertOne) UpdateUpdatedAt() *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateUpdatedAt()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetStatus sets the "status" field.
|
|
|
+func (u *MessageRecordsUpsertOne) SetStatus(v uint8) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetStatus(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// AddStatus adds v to the "status" field.
|
|
|
+func (u *MessageRecordsUpsertOne) AddStatus(v uint8) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.AddStatus(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertOne) UpdateStatus() *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateStatus()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// ClearStatus clears the value of the "status" field.
|
|
|
+func (u *MessageRecordsUpsertOne) ClearStatus() *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.ClearStatus()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetDeletedAt sets the "deleted_at" field.
|
|
|
+func (u *MessageRecordsUpsertOne) SetDeletedAt(v time.Time) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetDeletedAt(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertOne) UpdateDeletedAt() *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateDeletedAt()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
|
+func (u *MessageRecordsUpsertOne) ClearDeletedAt() *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.ClearDeletedAt()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetBotWxid sets the "bot_wxid" field.
|
|
|
+func (u *MessageRecordsUpsertOne) SetBotWxid(v string) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetBotWxid(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateBotWxid sets the "bot_wxid" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertOne) UpdateBotWxid() *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateBotWxid()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetContactID sets the "contact_id" field.
|
|
|
+func (u *MessageRecordsUpsertOne) SetContactID(v int) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetContactID(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// AddContactID adds v to the "contact_id" field.
|
|
|
+func (u *MessageRecordsUpsertOne) AddContactID(v int) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.AddContactID(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateContactID sets the "contact_id" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertOne) UpdateContactID() *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateContactID()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetContactType sets the "contact_type" field.
|
|
|
+func (u *MessageRecordsUpsertOne) SetContactType(v int) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetContactType(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// AddContactType adds v to the "contact_type" field.
|
|
|
+func (u *MessageRecordsUpsertOne) AddContactType(v int) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.AddContactType(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateContactType sets the "contact_type" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertOne) UpdateContactType() *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateContactType()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetContactWxid sets the "contact_wxid" field.
|
|
|
+func (u *MessageRecordsUpsertOne) SetContactWxid(v string) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetContactWxid(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateContactWxid sets the "contact_wxid" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertOne) UpdateContactWxid() *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateContactWxid()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetContentType sets the "content_type" field.
|
|
|
+func (u *MessageRecordsUpsertOne) SetContentType(v int) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetContentType(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// AddContentType adds v to the "content_type" field.
|
|
|
+func (u *MessageRecordsUpsertOne) AddContentType(v int) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.AddContentType(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateContentType sets the "content_type" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertOne) UpdateContentType() *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateContentType()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetContent sets the "content" field.
|
|
|
+func (u *MessageRecordsUpsertOne) SetContent(v string) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetContent(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateContent sets the "content" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertOne) UpdateContent() *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateContent()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetErrorDetail sets the "error_detail" field.
|
|
|
+func (u *MessageRecordsUpsertOne) SetErrorDetail(v string) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetErrorDetail(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateErrorDetail sets the "error_detail" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertOne) UpdateErrorDetail() *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateErrorDetail()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetSendTime sets the "send_time" field.
|
|
|
+func (u *MessageRecordsUpsertOne) SetSendTime(v time.Time) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetSendTime(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateSendTime sets the "send_time" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertOne) UpdateSendTime() *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateSendTime()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// ClearSendTime clears the value of the "send_time" field.
|
|
|
+func (u *MessageRecordsUpsertOne) ClearSendTime() *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.ClearSendTime()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetSourceType sets the "source_type" field.
|
|
|
+func (u *MessageRecordsUpsertOne) SetSourceType(v int) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetSourceType(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// AddSourceType adds v to the "source_type" field.
|
|
|
+func (u *MessageRecordsUpsertOne) AddSourceType(v int) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.AddSourceType(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateSourceType sets the "source_type" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertOne) UpdateSourceType() *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateSourceType()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetSourceID sets the "source_id" field.
|
|
|
+func (u *MessageRecordsUpsertOne) SetSourceID(v int) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetSourceID(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// AddSourceID adds v to the "source_id" field.
|
|
|
+func (u *MessageRecordsUpsertOne) AddSourceID(v int) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.AddSourceID(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateSourceID sets the "source_id" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertOne) UpdateSourceID() *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateSourceID()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetSubSourceID sets the "sub_source_id" field.
|
|
|
+func (u *MessageRecordsUpsertOne) SetSubSourceID(v int) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetSubSourceID(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// AddSubSourceID adds v to the "sub_source_id" field.
|
|
|
+func (u *MessageRecordsUpsertOne) AddSubSourceID(v int) *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.AddSubSourceID(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateSubSourceID sets the "sub_source_id" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertOne) UpdateSubSourceID() *MessageRecordsUpsertOne {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateSubSourceID()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// Exec executes the query.
|
|
|
+func (u *MessageRecordsUpsertOne) Exec(ctx context.Context) error {
|
|
|
+ if len(u.create.conflict) == 0 {
|
|
|
+ return errors.New("ent: missing options for MessageRecordsCreate.OnConflict")
|
|
|
+ }
|
|
|
+ return u.create.Exec(ctx)
|
|
|
+}
|
|
|
+
|
|
|
+// ExecX is like Exec, but panics if an error occurs.
|
|
|
+func (u *MessageRecordsUpsertOne) 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 *MessageRecordsUpsertOne) 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 *MessageRecordsUpsertOne) IDX(ctx context.Context) uint64 {
|
|
|
+ id, err := u.ID(ctx)
|
|
|
+ if err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+ return id
|
|
|
+}
|
|
|
+
|
|
|
+// MessageRecordsCreateBulk is the builder for creating many MessageRecords entities in bulk.
|
|
|
+type MessageRecordsCreateBulk struct {
|
|
|
+ config
|
|
|
+ err error
|
|
|
+ builders []*MessageRecordsCreate
|
|
|
+ conflict []sql.ConflictOption
|
|
|
+}
|
|
|
+
|
|
|
+// Save creates the MessageRecords entities in the database.
|
|
|
+func (mrcb *MessageRecordsCreateBulk) Save(ctx context.Context) ([]*MessageRecords, error) {
|
|
|
+ if mrcb.err != nil {
|
|
|
+ return nil, mrcb.err
|
|
|
+ }
|
|
|
+ specs := make([]*sqlgraph.CreateSpec, len(mrcb.builders))
|
|
|
+ nodes := make([]*MessageRecords, len(mrcb.builders))
|
|
|
+ mutators := make([]Mutator, len(mrcb.builders))
|
|
|
+ for i := range mrcb.builders {
|
|
|
+ func(i int, root context.Context) {
|
|
|
+ builder := mrcb.builders[i]
|
|
|
+ builder.defaults()
|
|
|
+ var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
|
+ mutation, ok := m.(*MessageRecordsMutation)
|
|
|
+ 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, mrcb.builders[i+1].mutation)
|
|
|
+ } else {
|
|
|
+ spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
|
|
+ spec.OnConflict = mrcb.conflict
|
|
|
+ // Invoke the actual operation on the latest mutation in the chain.
|
|
|
+ if err = sqlgraph.BatchCreate(ctx, mrcb.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, mrcb.builders[0].mutation); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nodes, nil
|
|
|
+}
|
|
|
+
|
|
|
+// SaveX is like Save, but panics if an error occurs.
|
|
|
+func (mrcb *MessageRecordsCreateBulk) SaveX(ctx context.Context) []*MessageRecords {
|
|
|
+ v, err := mrcb.Save(ctx)
|
|
|
+ if err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+ return v
|
|
|
+}
|
|
|
+
|
|
|
+// Exec executes the query.
|
|
|
+func (mrcb *MessageRecordsCreateBulk) Exec(ctx context.Context) error {
|
|
|
+ _, err := mrcb.Save(ctx)
|
|
|
+ return err
|
|
|
+}
|
|
|
+
|
|
|
+// ExecX is like Exec, but panics if an error occurs.
|
|
|
+func (mrcb *MessageRecordsCreateBulk) ExecX(ctx context.Context) {
|
|
|
+ if err := mrcb.Exec(ctx); err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
|
+// of the `INSERT` statement. For example:
|
|
|
+//
|
|
|
+// client.MessageRecords.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.MessageRecordsUpsert) {
|
|
|
+// SetCreatedAt(v+v).
|
|
|
+// }).
|
|
|
+// Exec(ctx)
|
|
|
+func (mrcb *MessageRecordsCreateBulk) OnConflict(opts ...sql.ConflictOption) *MessageRecordsUpsertBulk {
|
|
|
+ mrcb.conflict = opts
|
|
|
+ return &MessageRecordsUpsertBulk{
|
|
|
+ create: mrcb,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// OnConflictColumns calls `OnConflict` and configures the columns
|
|
|
+// as conflict target. Using this option is equivalent to using:
|
|
|
+//
|
|
|
+// client.MessageRecords.Create().
|
|
|
+// OnConflict(sql.ConflictColumns(columns...)).
|
|
|
+// Exec(ctx)
|
|
|
+func (mrcb *MessageRecordsCreateBulk) OnConflictColumns(columns ...string) *MessageRecordsUpsertBulk {
|
|
|
+ mrcb.conflict = append(mrcb.conflict, sql.ConflictColumns(columns...))
|
|
|
+ return &MessageRecordsUpsertBulk{
|
|
|
+ create: mrcb,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// MessageRecordsUpsertBulk is the builder for "upsert"-ing
|
|
|
+// a bulk of MessageRecords nodes.
|
|
|
+type MessageRecordsUpsertBulk struct {
|
|
|
+ create *MessageRecordsCreateBulk
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateNewValues updates the mutable fields using the new values that
|
|
|
+// were set on create. Using this option is equivalent to using:
|
|
|
+//
|
|
|
+// client.MessageRecords.Create().
|
|
|
+// OnConflict(
|
|
|
+// sql.ResolveWithNewValues(),
|
|
|
+// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
|
+// u.SetIgnore(messagerecords.FieldID)
|
|
|
+// }),
|
|
|
+// ).
|
|
|
+// Exec(ctx)
|
|
|
+func (u *MessageRecordsUpsertBulk) UpdateNewValues() *MessageRecordsUpsertBulk {
|
|
|
+ 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(messagerecords.FieldID)
|
|
|
+ }
|
|
|
+ if _, exists := b.mutation.CreatedAt(); exists {
|
|
|
+ s.SetIgnore(messagerecords.FieldCreatedAt)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }))
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// Ignore sets each column to itself in case of conflict.
|
|
|
+// Using this option is equivalent to using:
|
|
|
+//
|
|
|
+// client.MessageRecords.Create().
|
|
|
+// OnConflict(sql.ResolveWithIgnore()).
|
|
|
+// Exec(ctx)
|
|
|
+func (u *MessageRecordsUpsertBulk) Ignore() *MessageRecordsUpsertBulk {
|
|
|
+ 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 *MessageRecordsUpsertBulk) DoNothing() *MessageRecordsUpsertBulk {
|
|
|
+ u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// Update allows overriding fields `UPDATE` values. See the MessageRecordsCreateBulk.OnConflict
|
|
|
+// documentation for more info.
|
|
|
+func (u *MessageRecordsUpsertBulk) Update(set func(*MessageRecordsUpsert)) *MessageRecordsUpsertBulk {
|
|
|
+ u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
|
+ set(&MessageRecordsUpsert{UpdateSet: update})
|
|
|
+ }))
|
|
|
+ return u
|
|
|
+}
|
|
|
+
|
|
|
+// SetUpdatedAt sets the "updated_at" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) SetUpdatedAt(v time.Time) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetUpdatedAt(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertBulk) UpdateUpdatedAt() *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateUpdatedAt()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetStatus sets the "status" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) SetStatus(v uint8) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetStatus(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// AddStatus adds v to the "status" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) AddStatus(v uint8) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.AddStatus(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertBulk) UpdateStatus() *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateStatus()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// ClearStatus clears the value of the "status" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) ClearStatus() *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.ClearStatus()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetDeletedAt sets the "deleted_at" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) SetDeletedAt(v time.Time) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetDeletedAt(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertBulk) UpdateDeletedAt() *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateDeletedAt()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) ClearDeletedAt() *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.ClearDeletedAt()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetBotWxid sets the "bot_wxid" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) SetBotWxid(v string) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetBotWxid(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateBotWxid sets the "bot_wxid" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertBulk) UpdateBotWxid() *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateBotWxid()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetContactID sets the "contact_id" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) SetContactID(v int) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetContactID(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// AddContactID adds v to the "contact_id" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) AddContactID(v int) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.AddContactID(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateContactID sets the "contact_id" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertBulk) UpdateContactID() *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateContactID()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetContactType sets the "contact_type" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) SetContactType(v int) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetContactType(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// AddContactType adds v to the "contact_type" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) AddContactType(v int) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.AddContactType(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateContactType sets the "contact_type" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertBulk) UpdateContactType() *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateContactType()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetContactWxid sets the "contact_wxid" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) SetContactWxid(v string) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetContactWxid(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateContactWxid sets the "contact_wxid" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertBulk) UpdateContactWxid() *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateContactWxid()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetContentType sets the "content_type" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) SetContentType(v int) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetContentType(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// AddContentType adds v to the "content_type" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) AddContentType(v int) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.AddContentType(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateContentType sets the "content_type" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertBulk) UpdateContentType() *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateContentType()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetContent sets the "content" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) SetContent(v string) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetContent(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateContent sets the "content" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertBulk) UpdateContent() *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateContent()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetErrorDetail sets the "error_detail" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) SetErrorDetail(v string) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetErrorDetail(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateErrorDetail sets the "error_detail" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertBulk) UpdateErrorDetail() *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateErrorDetail()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetSendTime sets the "send_time" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) SetSendTime(v time.Time) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetSendTime(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateSendTime sets the "send_time" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertBulk) UpdateSendTime() *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateSendTime()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// ClearSendTime clears the value of the "send_time" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) ClearSendTime() *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.ClearSendTime()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetSourceType sets the "source_type" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) SetSourceType(v int) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetSourceType(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// AddSourceType adds v to the "source_type" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) AddSourceType(v int) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.AddSourceType(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateSourceType sets the "source_type" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertBulk) UpdateSourceType() *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateSourceType()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetSourceID sets the "source_id" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) SetSourceID(v int) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetSourceID(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// AddSourceID adds v to the "source_id" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) AddSourceID(v int) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.AddSourceID(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateSourceID sets the "source_id" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertBulk) UpdateSourceID() *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateSourceID()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SetSubSourceID sets the "sub_source_id" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) SetSubSourceID(v int) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.SetSubSourceID(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// AddSubSourceID adds v to the "sub_source_id" field.
|
|
|
+func (u *MessageRecordsUpsertBulk) AddSubSourceID(v int) *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.AddSubSourceID(v)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateSubSourceID sets the "sub_source_id" field to the value that was provided on create.
|
|
|
+func (u *MessageRecordsUpsertBulk) UpdateSubSourceID() *MessageRecordsUpsertBulk {
|
|
|
+ return u.Update(func(s *MessageRecordsUpsert) {
|
|
|
+ s.UpdateSubSourceID()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// Exec executes the query.
|
|
|
+func (u *MessageRecordsUpsertBulk) 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 MessageRecordsCreateBulk instead", i)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(u.create.conflict) == 0 {
|
|
|
+ return errors.New("ent: missing options for MessageRecordsCreateBulk.OnConflict")
|
|
|
+ }
|
|
|
+ return u.create.Exec(ctx)
|
|
|
+}
|
|
|
+
|
|
|
+// ExecX is like Exec, but panics if an error occurs.
|
|
|
+func (u *MessageRecordsUpsertBulk) ExecX(ctx context.Context) {
|
|
|
+ if err := u.create.Exec(ctx); err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+}
|