123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "wechat-api/ent/addwechatfriendlog"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- )
- // AddWechatFriendLogCreate is the builder for creating a AddWechatFriendLog entity.
- type AddWechatFriendLogCreate struct {
- config
- mutation *AddWechatFriendLogMutation
- hooks []Hook
- conflict []sql.ConflictOption
- }
- // SetOwnerWxID sets the "owner_wx_id" field.
- func (awflc *AddWechatFriendLogCreate) SetOwnerWxID(s string) *AddWechatFriendLogCreate {
- awflc.mutation.SetOwnerWxID(s)
- return awflc
- }
- // SetNillableOwnerWxID sets the "owner_wx_id" field if the given value is not nil.
- func (awflc *AddWechatFriendLogCreate) SetNillableOwnerWxID(s *string) *AddWechatFriendLogCreate {
- if s != nil {
- awflc.SetOwnerWxID(*s)
- }
- return awflc
- }
- // SetOwnerWxType sets the "owner_wx_type" field.
- func (awflc *AddWechatFriendLogCreate) SetOwnerWxType(i int) *AddWechatFriendLogCreate {
- awflc.mutation.SetOwnerWxType(i)
- return awflc
- }
- // SetNillableOwnerWxType sets the "owner_wx_type" field if the given value is not nil.
- func (awflc *AddWechatFriendLogCreate) SetNillableOwnerWxType(i *int) *AddWechatFriendLogCreate {
- if i != nil {
- awflc.SetOwnerWxType(*i)
- }
- return awflc
- }
- // SetFindContent sets the "find_content" field.
- func (awflc *AddWechatFriendLogCreate) SetFindContent(s string) *AddWechatFriendLogCreate {
- awflc.mutation.SetFindContent(s)
- return awflc
- }
- // SetNillableFindContent sets the "find_content" field if the given value is not nil.
- func (awflc *AddWechatFriendLogCreate) SetNillableFindContent(s *string) *AddWechatFriendLogCreate {
- if s != nil {
- awflc.SetFindContent(*s)
- }
- return awflc
- }
- // SetMessage sets the "message" field.
- func (awflc *AddWechatFriendLogCreate) SetMessage(s string) *AddWechatFriendLogCreate {
- awflc.mutation.SetMessage(s)
- return awflc
- }
- // SetNillableMessage sets the "message" field if the given value is not nil.
- func (awflc *AddWechatFriendLogCreate) SetNillableMessage(s *string) *AddWechatFriendLogCreate {
- if s != nil {
- awflc.SetMessage(*s)
- }
- return awflc
- }
- // SetFindRequest sets the "find_request" field.
- func (awflc *AddWechatFriendLogCreate) SetFindRequest(m map[string]interface{}) *AddWechatFriendLogCreate {
- awflc.mutation.SetFindRequest(m)
- return awflc
- }
- // SetFindResult sets the "find_result" field.
- func (awflc *AddWechatFriendLogCreate) SetFindResult(m map[string]interface{}) *AddWechatFriendLogCreate {
- awflc.mutation.SetFindResult(m)
- return awflc
- }
- // SetIsCanAdd sets the "is_can_add" field.
- func (awflc *AddWechatFriendLogCreate) SetIsCanAdd(i int) *AddWechatFriendLogCreate {
- awflc.mutation.SetIsCanAdd(i)
- return awflc
- }
- // SetNillableIsCanAdd sets the "is_can_add" field if the given value is not nil.
- func (awflc *AddWechatFriendLogCreate) SetNillableIsCanAdd(i *int) *AddWechatFriendLogCreate {
- if i != nil {
- awflc.SetIsCanAdd(*i)
- }
- return awflc
- }
- // SetTaskCount sets the "task_count" field.
- func (awflc *AddWechatFriendLogCreate) SetTaskCount(i int) *AddWechatFriendLogCreate {
- awflc.mutation.SetTaskCount(i)
- return awflc
- }
- // SetNillableTaskCount sets the "task_count" field if the given value is not nil.
- func (awflc *AddWechatFriendLogCreate) SetNillableTaskCount(i *int) *AddWechatFriendLogCreate {
- if i != nil {
- awflc.SetTaskCount(*i)
- }
- return awflc
- }
- // SetTaskID sets the "task_id" field.
- func (awflc *AddWechatFriendLogCreate) SetTaskID(i int64) *AddWechatFriendLogCreate {
- awflc.mutation.SetTaskID(i)
- return awflc
- }
- // SetNillableTaskID sets the "task_id" field if the given value is not nil.
- func (awflc *AddWechatFriendLogCreate) SetNillableTaskID(i *int64) *AddWechatFriendLogCreate {
- if i != nil {
- awflc.SetTaskID(*i)
- }
- return awflc
- }
- // SetAddRequest sets the "add_request" field.
- func (awflc *AddWechatFriendLogCreate) SetAddRequest(m map[string]interface{}) *AddWechatFriendLogCreate {
- awflc.mutation.SetAddRequest(m)
- return awflc
- }
- // SetAddResult sets the "add_result" field.
- func (awflc *AddWechatFriendLogCreate) SetAddResult(m map[string]interface{}) *AddWechatFriendLogCreate {
- awflc.mutation.SetAddResult(m)
- return awflc
- }
- // SetCreatedAt sets the "created_at" field.
- func (awflc *AddWechatFriendLogCreate) SetCreatedAt(i int64) *AddWechatFriendLogCreate {
- awflc.mutation.SetCreatedAt(i)
- return awflc
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (awflc *AddWechatFriendLogCreate) SetNillableCreatedAt(i *int64) *AddWechatFriendLogCreate {
- if i != nil {
- awflc.SetCreatedAt(*i)
- }
- return awflc
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (awflc *AddWechatFriendLogCreate) SetUpdatedAt(i int64) *AddWechatFriendLogCreate {
- awflc.mutation.SetUpdatedAt(i)
- return awflc
- }
- // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
- func (awflc *AddWechatFriendLogCreate) SetNillableUpdatedAt(i *int64) *AddWechatFriendLogCreate {
- if i != nil {
- awflc.SetUpdatedAt(*i)
- }
- return awflc
- }
- // SetID sets the "id" field.
- func (awflc *AddWechatFriendLogCreate) SetID(i int64) *AddWechatFriendLogCreate {
- awflc.mutation.SetID(i)
- return awflc
- }
- // Mutation returns the AddWechatFriendLogMutation object of the builder.
- func (awflc *AddWechatFriendLogCreate) Mutation() *AddWechatFriendLogMutation {
- return awflc.mutation
- }
- // Save creates the AddWechatFriendLog in the database.
- func (awflc *AddWechatFriendLogCreate) Save(ctx context.Context) (*AddWechatFriendLog, error) {
- awflc.defaults()
- return withHooks(ctx, awflc.sqlSave, awflc.mutation, awflc.hooks)
- }
- // SaveX calls Save and panics if Save returns an error.
- func (awflc *AddWechatFriendLogCreate) SaveX(ctx context.Context) *AddWechatFriendLog {
- v, err := awflc.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (awflc *AddWechatFriendLogCreate) Exec(ctx context.Context) error {
- _, err := awflc.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (awflc *AddWechatFriendLogCreate) ExecX(ctx context.Context) {
- if err := awflc.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (awflc *AddWechatFriendLogCreate) defaults() {
- if _, ok := awflc.mutation.OwnerWxID(); !ok {
- v := addwechatfriendlog.DefaultOwnerWxID
- awflc.mutation.SetOwnerWxID(v)
- }
- if _, ok := awflc.mutation.OwnerWxType(); !ok {
- v := addwechatfriendlog.DefaultOwnerWxType
- awflc.mutation.SetOwnerWxType(v)
- }
- if _, ok := awflc.mutation.FindContent(); !ok {
- v := addwechatfriendlog.DefaultFindContent
- awflc.mutation.SetFindContent(v)
- }
- if _, ok := awflc.mutation.Message(); !ok {
- v := addwechatfriendlog.DefaultMessage
- awflc.mutation.SetMessage(v)
- }
- if _, ok := awflc.mutation.IsCanAdd(); !ok {
- v := addwechatfriendlog.DefaultIsCanAdd
- awflc.mutation.SetIsCanAdd(v)
- }
- if _, ok := awflc.mutation.TaskCount(); !ok {
- v := addwechatfriendlog.DefaultTaskCount
- awflc.mutation.SetTaskCount(v)
- }
- if _, ok := awflc.mutation.TaskID(); !ok {
- v := addwechatfriendlog.DefaultTaskID
- awflc.mutation.SetTaskID(v)
- }
- if _, ok := awflc.mutation.CreatedAt(); !ok {
- v := addwechatfriendlog.DefaultCreatedAt()
- awflc.mutation.SetCreatedAt(v)
- }
- if _, ok := awflc.mutation.UpdatedAt(); !ok {
- v := addwechatfriendlog.DefaultUpdatedAt()
- awflc.mutation.SetUpdatedAt(v)
- }
- }
- // check runs all checks and user-defined validators on the builder.
- func (awflc *AddWechatFriendLogCreate) check() error {
- if _, ok := awflc.mutation.OwnerWxID(); !ok {
- return &ValidationError{Name: "owner_wx_id", err: errors.New(`ent: missing required field "AddWechatFriendLog.owner_wx_id"`)}
- }
- if v, ok := awflc.mutation.OwnerWxID(); ok {
- if err := addwechatfriendlog.OwnerWxIDValidator(v); err != nil {
- return &ValidationError{Name: "owner_wx_id", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.owner_wx_id": %w`, err)}
- }
- }
- if _, ok := awflc.mutation.OwnerWxType(); !ok {
- return &ValidationError{Name: "owner_wx_type", err: errors.New(`ent: missing required field "AddWechatFriendLog.owner_wx_type"`)}
- }
- if _, ok := awflc.mutation.FindContent(); !ok {
- return &ValidationError{Name: "find_content", err: errors.New(`ent: missing required field "AddWechatFriendLog.find_content"`)}
- }
- if v, ok := awflc.mutation.FindContent(); ok {
- if err := addwechatfriendlog.FindContentValidator(v); err != nil {
- return &ValidationError{Name: "find_content", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.find_content": %w`, err)}
- }
- }
- if _, ok := awflc.mutation.Message(); !ok {
- return &ValidationError{Name: "message", err: errors.New(`ent: missing required field "AddWechatFriendLog.message"`)}
- }
- if v, ok := awflc.mutation.Message(); ok {
- if err := addwechatfriendlog.MessageValidator(v); err != nil {
- return &ValidationError{Name: "message", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.message": %w`, err)}
- }
- }
- if _, ok := awflc.mutation.IsCanAdd(); !ok {
- return &ValidationError{Name: "is_can_add", err: errors.New(`ent: missing required field "AddWechatFriendLog.is_can_add"`)}
- }
- if _, ok := awflc.mutation.TaskCount(); !ok {
- return &ValidationError{Name: "task_count", err: errors.New(`ent: missing required field "AddWechatFriendLog.task_count"`)}
- }
- if _, ok := awflc.mutation.TaskID(); !ok {
- return &ValidationError{Name: "task_id", err: errors.New(`ent: missing required field "AddWechatFriendLog.task_id"`)}
- }
- if _, ok := awflc.mutation.CreatedAt(); !ok {
- return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "AddWechatFriendLog.created_at"`)}
- }
- if _, ok := awflc.mutation.UpdatedAt(); !ok {
- return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "AddWechatFriendLog.updated_at"`)}
- }
- return nil
- }
- func (awflc *AddWechatFriendLogCreate) sqlSave(ctx context.Context) (*AddWechatFriendLog, error) {
- if err := awflc.check(); err != nil {
- return nil, err
- }
- _node, _spec := awflc.createSpec()
- if err := sqlgraph.CreateNode(ctx, awflc.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 = int64(id)
- }
- awflc.mutation.id = &_node.ID
- awflc.mutation.done = true
- return _node, nil
- }
- func (awflc *AddWechatFriendLogCreate) createSpec() (*AddWechatFriendLog, *sqlgraph.CreateSpec) {
- var (
- _node = &AddWechatFriendLog{config: awflc.config}
- _spec = sqlgraph.NewCreateSpec(addwechatfriendlog.Table, sqlgraph.NewFieldSpec(addwechatfriendlog.FieldID, field.TypeInt64))
- )
- _spec.OnConflict = awflc.conflict
- if id, ok := awflc.mutation.ID(); ok {
- _node.ID = id
- _spec.ID.Value = id
- }
- if value, ok := awflc.mutation.OwnerWxID(); ok {
- _spec.SetField(addwechatfriendlog.FieldOwnerWxID, field.TypeString, value)
- _node.OwnerWxID = value
- }
- if value, ok := awflc.mutation.OwnerWxType(); ok {
- _spec.SetField(addwechatfriendlog.FieldOwnerWxType, field.TypeInt, value)
- _node.OwnerWxType = value
- }
- if value, ok := awflc.mutation.FindContent(); ok {
- _spec.SetField(addwechatfriendlog.FieldFindContent, field.TypeString, value)
- _node.FindContent = value
- }
- if value, ok := awflc.mutation.Message(); ok {
- _spec.SetField(addwechatfriendlog.FieldMessage, field.TypeString, value)
- _node.Message = value
- }
- if value, ok := awflc.mutation.FindRequest(); ok {
- _spec.SetField(addwechatfriendlog.FieldFindRequest, field.TypeJSON, value)
- _node.FindRequest = value
- }
- if value, ok := awflc.mutation.FindResult(); ok {
- _spec.SetField(addwechatfriendlog.FieldFindResult, field.TypeJSON, value)
- _node.FindResult = value
- }
- if value, ok := awflc.mutation.IsCanAdd(); ok {
- _spec.SetField(addwechatfriendlog.FieldIsCanAdd, field.TypeInt, value)
- _node.IsCanAdd = value
- }
- if value, ok := awflc.mutation.TaskCount(); ok {
- _spec.SetField(addwechatfriendlog.FieldTaskCount, field.TypeInt, value)
- _node.TaskCount = value
- }
- if value, ok := awflc.mutation.TaskID(); ok {
- _spec.SetField(addwechatfriendlog.FieldTaskID, field.TypeInt64, value)
- _node.TaskID = value
- }
- if value, ok := awflc.mutation.AddRequest(); ok {
- _spec.SetField(addwechatfriendlog.FieldAddRequest, field.TypeJSON, value)
- _node.AddRequest = value
- }
- if value, ok := awflc.mutation.AddResult(); ok {
- _spec.SetField(addwechatfriendlog.FieldAddResult, field.TypeJSON, value)
- _node.AddResult = value
- }
- if value, ok := awflc.mutation.CreatedAt(); ok {
- _spec.SetField(addwechatfriendlog.FieldCreatedAt, field.TypeInt64, value)
- _node.CreatedAt = value
- }
- if value, ok := awflc.mutation.UpdatedAt(); ok {
- _spec.SetField(addwechatfriendlog.FieldUpdatedAt, field.TypeInt64, value)
- _node.UpdatedAt = value
- }
- return _node, _spec
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.AddWechatFriendLog.Create().
- // SetOwnerWxID(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.AddWechatFriendLogUpsert) {
- // SetOwnerWxID(v+v).
- // }).
- // Exec(ctx)
- func (awflc *AddWechatFriendLogCreate) OnConflict(opts ...sql.ConflictOption) *AddWechatFriendLogUpsertOne {
- awflc.conflict = opts
- return &AddWechatFriendLogUpsertOne{
- create: awflc,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.AddWechatFriendLog.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (awflc *AddWechatFriendLogCreate) OnConflictColumns(columns ...string) *AddWechatFriendLogUpsertOne {
- awflc.conflict = append(awflc.conflict, sql.ConflictColumns(columns...))
- return &AddWechatFriendLogUpsertOne{
- create: awflc,
- }
- }
- type (
- // AddWechatFriendLogUpsertOne is the builder for "upsert"-ing
- // one AddWechatFriendLog node.
- AddWechatFriendLogUpsertOne struct {
- create *AddWechatFriendLogCreate
- }
- // AddWechatFriendLogUpsert is the "OnConflict" setter.
- AddWechatFriendLogUpsert struct {
- *sql.UpdateSet
- }
- )
- // SetOwnerWxID sets the "owner_wx_id" field.
- func (u *AddWechatFriendLogUpsert) SetOwnerWxID(v string) *AddWechatFriendLogUpsert {
- u.Set(addwechatfriendlog.FieldOwnerWxID, v)
- return u
- }
- // UpdateOwnerWxID sets the "owner_wx_id" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsert) UpdateOwnerWxID() *AddWechatFriendLogUpsert {
- u.SetExcluded(addwechatfriendlog.FieldOwnerWxID)
- return u
- }
- // SetOwnerWxType sets the "owner_wx_type" field.
- func (u *AddWechatFriendLogUpsert) SetOwnerWxType(v int) *AddWechatFriendLogUpsert {
- u.Set(addwechatfriendlog.FieldOwnerWxType, v)
- return u
- }
- // UpdateOwnerWxType sets the "owner_wx_type" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsert) UpdateOwnerWxType() *AddWechatFriendLogUpsert {
- u.SetExcluded(addwechatfriendlog.FieldOwnerWxType)
- return u
- }
- // AddOwnerWxType adds v to the "owner_wx_type" field.
- func (u *AddWechatFriendLogUpsert) AddOwnerWxType(v int) *AddWechatFriendLogUpsert {
- u.Add(addwechatfriendlog.FieldOwnerWxType, v)
- return u
- }
- // SetFindContent sets the "find_content" field.
- func (u *AddWechatFriendLogUpsert) SetFindContent(v string) *AddWechatFriendLogUpsert {
- u.Set(addwechatfriendlog.FieldFindContent, v)
- return u
- }
- // UpdateFindContent sets the "find_content" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsert) UpdateFindContent() *AddWechatFriendLogUpsert {
- u.SetExcluded(addwechatfriendlog.FieldFindContent)
- return u
- }
- // SetMessage sets the "message" field.
- func (u *AddWechatFriendLogUpsert) SetMessage(v string) *AddWechatFriendLogUpsert {
- u.Set(addwechatfriendlog.FieldMessage, v)
- return u
- }
- // UpdateMessage sets the "message" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsert) UpdateMessage() *AddWechatFriendLogUpsert {
- u.SetExcluded(addwechatfriendlog.FieldMessage)
- return u
- }
- // SetFindRequest sets the "find_request" field.
- func (u *AddWechatFriendLogUpsert) SetFindRequest(v map[string]interface{}) *AddWechatFriendLogUpsert {
- u.Set(addwechatfriendlog.FieldFindRequest, v)
- return u
- }
- // UpdateFindRequest sets the "find_request" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsert) UpdateFindRequest() *AddWechatFriendLogUpsert {
- u.SetExcluded(addwechatfriendlog.FieldFindRequest)
- return u
- }
- // ClearFindRequest clears the value of the "find_request" field.
- func (u *AddWechatFriendLogUpsert) ClearFindRequest() *AddWechatFriendLogUpsert {
- u.SetNull(addwechatfriendlog.FieldFindRequest)
- return u
- }
- // SetFindResult sets the "find_result" field.
- func (u *AddWechatFriendLogUpsert) SetFindResult(v map[string]interface{}) *AddWechatFriendLogUpsert {
- u.Set(addwechatfriendlog.FieldFindResult, v)
- return u
- }
- // UpdateFindResult sets the "find_result" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsert) UpdateFindResult() *AddWechatFriendLogUpsert {
- u.SetExcluded(addwechatfriendlog.FieldFindResult)
- return u
- }
- // ClearFindResult clears the value of the "find_result" field.
- func (u *AddWechatFriendLogUpsert) ClearFindResult() *AddWechatFriendLogUpsert {
- u.SetNull(addwechatfriendlog.FieldFindResult)
- return u
- }
- // SetIsCanAdd sets the "is_can_add" field.
- func (u *AddWechatFriendLogUpsert) SetIsCanAdd(v int) *AddWechatFriendLogUpsert {
- u.Set(addwechatfriendlog.FieldIsCanAdd, v)
- return u
- }
- // UpdateIsCanAdd sets the "is_can_add" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsert) UpdateIsCanAdd() *AddWechatFriendLogUpsert {
- u.SetExcluded(addwechatfriendlog.FieldIsCanAdd)
- return u
- }
- // AddIsCanAdd adds v to the "is_can_add" field.
- func (u *AddWechatFriendLogUpsert) AddIsCanAdd(v int) *AddWechatFriendLogUpsert {
- u.Add(addwechatfriendlog.FieldIsCanAdd, v)
- return u
- }
- // SetTaskCount sets the "task_count" field.
- func (u *AddWechatFriendLogUpsert) SetTaskCount(v int) *AddWechatFriendLogUpsert {
- u.Set(addwechatfriendlog.FieldTaskCount, v)
- return u
- }
- // UpdateTaskCount sets the "task_count" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsert) UpdateTaskCount() *AddWechatFriendLogUpsert {
- u.SetExcluded(addwechatfriendlog.FieldTaskCount)
- return u
- }
- // AddTaskCount adds v to the "task_count" field.
- func (u *AddWechatFriendLogUpsert) AddTaskCount(v int) *AddWechatFriendLogUpsert {
- u.Add(addwechatfriendlog.FieldTaskCount, v)
- return u
- }
- // SetTaskID sets the "task_id" field.
- func (u *AddWechatFriendLogUpsert) SetTaskID(v int64) *AddWechatFriendLogUpsert {
- u.Set(addwechatfriendlog.FieldTaskID, v)
- return u
- }
- // UpdateTaskID sets the "task_id" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsert) UpdateTaskID() *AddWechatFriendLogUpsert {
- u.SetExcluded(addwechatfriendlog.FieldTaskID)
- return u
- }
- // AddTaskID adds v to the "task_id" field.
- func (u *AddWechatFriendLogUpsert) AddTaskID(v int64) *AddWechatFriendLogUpsert {
- u.Add(addwechatfriendlog.FieldTaskID, v)
- return u
- }
- // SetAddRequest sets the "add_request" field.
- func (u *AddWechatFriendLogUpsert) SetAddRequest(v map[string]interface{}) *AddWechatFriendLogUpsert {
- u.Set(addwechatfriendlog.FieldAddRequest, v)
- return u
- }
- // UpdateAddRequest sets the "add_request" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsert) UpdateAddRequest() *AddWechatFriendLogUpsert {
- u.SetExcluded(addwechatfriendlog.FieldAddRequest)
- return u
- }
- // ClearAddRequest clears the value of the "add_request" field.
- func (u *AddWechatFriendLogUpsert) ClearAddRequest() *AddWechatFriendLogUpsert {
- u.SetNull(addwechatfriendlog.FieldAddRequest)
- return u
- }
- // SetAddResult sets the "add_result" field.
- func (u *AddWechatFriendLogUpsert) SetAddResult(v map[string]interface{}) *AddWechatFriendLogUpsert {
- u.Set(addwechatfriendlog.FieldAddResult, v)
- return u
- }
- // UpdateAddResult sets the "add_result" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsert) UpdateAddResult() *AddWechatFriendLogUpsert {
- u.SetExcluded(addwechatfriendlog.FieldAddResult)
- return u
- }
- // ClearAddResult clears the value of the "add_result" field.
- func (u *AddWechatFriendLogUpsert) ClearAddResult() *AddWechatFriendLogUpsert {
- u.SetNull(addwechatfriendlog.FieldAddResult)
- return u
- }
- // SetCreatedAt sets the "created_at" field.
- func (u *AddWechatFriendLogUpsert) SetCreatedAt(v int64) *AddWechatFriendLogUpsert {
- u.Set(addwechatfriendlog.FieldCreatedAt, v)
- return u
- }
- // UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsert) UpdateCreatedAt() *AddWechatFriendLogUpsert {
- u.SetExcluded(addwechatfriendlog.FieldCreatedAt)
- return u
- }
- // AddCreatedAt adds v to the "created_at" field.
- func (u *AddWechatFriendLogUpsert) AddCreatedAt(v int64) *AddWechatFriendLogUpsert {
- u.Add(addwechatfriendlog.FieldCreatedAt, v)
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *AddWechatFriendLogUpsert) SetUpdatedAt(v int64) *AddWechatFriendLogUpsert {
- u.Set(addwechatfriendlog.FieldUpdatedAt, v)
- return u
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsert) UpdateUpdatedAt() *AddWechatFriendLogUpsert {
- u.SetExcluded(addwechatfriendlog.FieldUpdatedAt)
- return u
- }
- // AddUpdatedAt adds v to the "updated_at" field.
- func (u *AddWechatFriendLogUpsert) AddUpdatedAt(v int64) *AddWechatFriendLogUpsert {
- u.Add(addwechatfriendlog.FieldUpdatedAt, 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.AddWechatFriendLog.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(addwechatfriendlog.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *AddWechatFriendLogUpsertOne) UpdateNewValues() *AddWechatFriendLogUpsertOne {
- 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(addwechatfriendlog.FieldID)
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.AddWechatFriendLog.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *AddWechatFriendLogUpsertOne) Ignore() *AddWechatFriendLogUpsertOne {
- 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 *AddWechatFriendLogUpsertOne) DoNothing() *AddWechatFriendLogUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the AddWechatFriendLogCreate.OnConflict
- // documentation for more info.
- func (u *AddWechatFriendLogUpsertOne) Update(set func(*AddWechatFriendLogUpsert)) *AddWechatFriendLogUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&AddWechatFriendLogUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetOwnerWxID sets the "owner_wx_id" field.
- func (u *AddWechatFriendLogUpsertOne) SetOwnerWxID(v string) *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetOwnerWxID(v)
- })
- }
- // UpdateOwnerWxID sets the "owner_wx_id" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertOne) UpdateOwnerWxID() *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateOwnerWxID()
- })
- }
- // SetOwnerWxType sets the "owner_wx_type" field.
- func (u *AddWechatFriendLogUpsertOne) SetOwnerWxType(v int) *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetOwnerWxType(v)
- })
- }
- // AddOwnerWxType adds v to the "owner_wx_type" field.
- func (u *AddWechatFriendLogUpsertOne) AddOwnerWxType(v int) *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.AddOwnerWxType(v)
- })
- }
- // UpdateOwnerWxType sets the "owner_wx_type" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertOne) UpdateOwnerWxType() *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateOwnerWxType()
- })
- }
- // SetFindContent sets the "find_content" field.
- func (u *AddWechatFriendLogUpsertOne) SetFindContent(v string) *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetFindContent(v)
- })
- }
- // UpdateFindContent sets the "find_content" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertOne) UpdateFindContent() *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateFindContent()
- })
- }
- // SetMessage sets the "message" field.
- func (u *AddWechatFriendLogUpsertOne) SetMessage(v string) *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetMessage(v)
- })
- }
- // UpdateMessage sets the "message" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertOne) UpdateMessage() *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateMessage()
- })
- }
- // SetFindRequest sets the "find_request" field.
- func (u *AddWechatFriendLogUpsertOne) SetFindRequest(v map[string]interface{}) *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetFindRequest(v)
- })
- }
- // UpdateFindRequest sets the "find_request" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertOne) UpdateFindRequest() *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateFindRequest()
- })
- }
- // ClearFindRequest clears the value of the "find_request" field.
- func (u *AddWechatFriendLogUpsertOne) ClearFindRequest() *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.ClearFindRequest()
- })
- }
- // SetFindResult sets the "find_result" field.
- func (u *AddWechatFriendLogUpsertOne) SetFindResult(v map[string]interface{}) *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetFindResult(v)
- })
- }
- // UpdateFindResult sets the "find_result" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertOne) UpdateFindResult() *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateFindResult()
- })
- }
- // ClearFindResult clears the value of the "find_result" field.
- func (u *AddWechatFriendLogUpsertOne) ClearFindResult() *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.ClearFindResult()
- })
- }
- // SetIsCanAdd sets the "is_can_add" field.
- func (u *AddWechatFriendLogUpsertOne) SetIsCanAdd(v int) *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetIsCanAdd(v)
- })
- }
- // AddIsCanAdd adds v to the "is_can_add" field.
- func (u *AddWechatFriendLogUpsertOne) AddIsCanAdd(v int) *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.AddIsCanAdd(v)
- })
- }
- // UpdateIsCanAdd sets the "is_can_add" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertOne) UpdateIsCanAdd() *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateIsCanAdd()
- })
- }
- // SetTaskCount sets the "task_count" field.
- func (u *AddWechatFriendLogUpsertOne) SetTaskCount(v int) *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetTaskCount(v)
- })
- }
- // AddTaskCount adds v to the "task_count" field.
- func (u *AddWechatFriendLogUpsertOne) AddTaskCount(v int) *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.AddTaskCount(v)
- })
- }
- // UpdateTaskCount sets the "task_count" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertOne) UpdateTaskCount() *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateTaskCount()
- })
- }
- // SetTaskID sets the "task_id" field.
- func (u *AddWechatFriendLogUpsertOne) SetTaskID(v int64) *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetTaskID(v)
- })
- }
- // AddTaskID adds v to the "task_id" field.
- func (u *AddWechatFriendLogUpsertOne) AddTaskID(v int64) *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.AddTaskID(v)
- })
- }
- // UpdateTaskID sets the "task_id" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertOne) UpdateTaskID() *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateTaskID()
- })
- }
- // SetAddRequest sets the "add_request" field.
- func (u *AddWechatFriendLogUpsertOne) SetAddRequest(v map[string]interface{}) *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetAddRequest(v)
- })
- }
- // UpdateAddRequest sets the "add_request" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertOne) UpdateAddRequest() *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateAddRequest()
- })
- }
- // ClearAddRequest clears the value of the "add_request" field.
- func (u *AddWechatFriendLogUpsertOne) ClearAddRequest() *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.ClearAddRequest()
- })
- }
- // SetAddResult sets the "add_result" field.
- func (u *AddWechatFriendLogUpsertOne) SetAddResult(v map[string]interface{}) *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetAddResult(v)
- })
- }
- // UpdateAddResult sets the "add_result" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertOne) UpdateAddResult() *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateAddResult()
- })
- }
- // ClearAddResult clears the value of the "add_result" field.
- func (u *AddWechatFriendLogUpsertOne) ClearAddResult() *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.ClearAddResult()
- })
- }
- // SetCreatedAt sets the "created_at" field.
- func (u *AddWechatFriendLogUpsertOne) SetCreatedAt(v int64) *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetCreatedAt(v)
- })
- }
- // AddCreatedAt adds v to the "created_at" field.
- func (u *AddWechatFriendLogUpsertOne) AddCreatedAt(v int64) *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.AddCreatedAt(v)
- })
- }
- // UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertOne) UpdateCreatedAt() *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateCreatedAt()
- })
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *AddWechatFriendLogUpsertOne) SetUpdatedAt(v int64) *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // AddUpdatedAt adds v to the "updated_at" field.
- func (u *AddWechatFriendLogUpsertOne) AddUpdatedAt(v int64) *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.AddUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertOne) UpdateUpdatedAt() *AddWechatFriendLogUpsertOne {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // Exec executes the query.
- func (u *AddWechatFriendLogUpsertOne) Exec(ctx context.Context) error {
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for AddWechatFriendLogCreate.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *AddWechatFriendLogUpsertOne) 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 *AddWechatFriendLogUpsertOne) ID(ctx context.Context) (id int64, 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 *AddWechatFriendLogUpsertOne) IDX(ctx context.Context) int64 {
- id, err := u.ID(ctx)
- if err != nil {
- panic(err)
- }
- return id
- }
- // AddWechatFriendLogCreateBulk is the builder for creating many AddWechatFriendLog entities in bulk.
- type AddWechatFriendLogCreateBulk struct {
- config
- err error
- builders []*AddWechatFriendLogCreate
- conflict []sql.ConflictOption
- }
- // Save creates the AddWechatFriendLog entities in the database.
- func (awflcb *AddWechatFriendLogCreateBulk) Save(ctx context.Context) ([]*AddWechatFriendLog, error) {
- if awflcb.err != nil {
- return nil, awflcb.err
- }
- specs := make([]*sqlgraph.CreateSpec, len(awflcb.builders))
- nodes := make([]*AddWechatFriendLog, len(awflcb.builders))
- mutators := make([]Mutator, len(awflcb.builders))
- for i := range awflcb.builders {
- func(i int, root context.Context) {
- builder := awflcb.builders[i]
- builder.defaults()
- var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
- mutation, ok := m.(*AddWechatFriendLogMutation)
- 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, awflcb.builders[i+1].mutation)
- } else {
- spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
- spec.OnConflict = awflcb.conflict
- // Invoke the actual operation on the latest mutation in the chain.
- if err = sqlgraph.BatchCreate(ctx, awflcb.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 = int64(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, awflcb.builders[0].mutation); err != nil {
- return nil, err
- }
- }
- return nodes, nil
- }
- // SaveX is like Save, but panics if an error occurs.
- func (awflcb *AddWechatFriendLogCreateBulk) SaveX(ctx context.Context) []*AddWechatFriendLog {
- v, err := awflcb.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (awflcb *AddWechatFriendLogCreateBulk) Exec(ctx context.Context) error {
- _, err := awflcb.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (awflcb *AddWechatFriendLogCreateBulk) ExecX(ctx context.Context) {
- if err := awflcb.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.AddWechatFriendLog.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.AddWechatFriendLogUpsert) {
- // SetOwnerWxID(v+v).
- // }).
- // Exec(ctx)
- func (awflcb *AddWechatFriendLogCreateBulk) OnConflict(opts ...sql.ConflictOption) *AddWechatFriendLogUpsertBulk {
- awflcb.conflict = opts
- return &AddWechatFriendLogUpsertBulk{
- create: awflcb,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.AddWechatFriendLog.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (awflcb *AddWechatFriendLogCreateBulk) OnConflictColumns(columns ...string) *AddWechatFriendLogUpsertBulk {
- awflcb.conflict = append(awflcb.conflict, sql.ConflictColumns(columns...))
- return &AddWechatFriendLogUpsertBulk{
- create: awflcb,
- }
- }
- // AddWechatFriendLogUpsertBulk is the builder for "upsert"-ing
- // a bulk of AddWechatFriendLog nodes.
- type AddWechatFriendLogUpsertBulk struct {
- create *AddWechatFriendLogCreateBulk
- }
- // UpdateNewValues updates the mutable fields using the new values that
- // were set on create. Using this option is equivalent to using:
- //
- // client.AddWechatFriendLog.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(addwechatfriendlog.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *AddWechatFriendLogUpsertBulk) UpdateNewValues() *AddWechatFriendLogUpsertBulk {
- 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(addwechatfriendlog.FieldID)
- }
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.AddWechatFriendLog.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *AddWechatFriendLogUpsertBulk) Ignore() *AddWechatFriendLogUpsertBulk {
- 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 *AddWechatFriendLogUpsertBulk) DoNothing() *AddWechatFriendLogUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the AddWechatFriendLogCreateBulk.OnConflict
- // documentation for more info.
- func (u *AddWechatFriendLogUpsertBulk) Update(set func(*AddWechatFriendLogUpsert)) *AddWechatFriendLogUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&AddWechatFriendLogUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetOwnerWxID sets the "owner_wx_id" field.
- func (u *AddWechatFriendLogUpsertBulk) SetOwnerWxID(v string) *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetOwnerWxID(v)
- })
- }
- // UpdateOwnerWxID sets the "owner_wx_id" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertBulk) UpdateOwnerWxID() *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateOwnerWxID()
- })
- }
- // SetOwnerWxType sets the "owner_wx_type" field.
- func (u *AddWechatFriendLogUpsertBulk) SetOwnerWxType(v int) *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetOwnerWxType(v)
- })
- }
- // AddOwnerWxType adds v to the "owner_wx_type" field.
- func (u *AddWechatFriendLogUpsertBulk) AddOwnerWxType(v int) *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.AddOwnerWxType(v)
- })
- }
- // UpdateOwnerWxType sets the "owner_wx_type" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertBulk) UpdateOwnerWxType() *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateOwnerWxType()
- })
- }
- // SetFindContent sets the "find_content" field.
- func (u *AddWechatFriendLogUpsertBulk) SetFindContent(v string) *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetFindContent(v)
- })
- }
- // UpdateFindContent sets the "find_content" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertBulk) UpdateFindContent() *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateFindContent()
- })
- }
- // SetMessage sets the "message" field.
- func (u *AddWechatFriendLogUpsertBulk) SetMessage(v string) *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetMessage(v)
- })
- }
- // UpdateMessage sets the "message" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertBulk) UpdateMessage() *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateMessage()
- })
- }
- // SetFindRequest sets the "find_request" field.
- func (u *AddWechatFriendLogUpsertBulk) SetFindRequest(v map[string]interface{}) *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetFindRequest(v)
- })
- }
- // UpdateFindRequest sets the "find_request" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertBulk) UpdateFindRequest() *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateFindRequest()
- })
- }
- // ClearFindRequest clears the value of the "find_request" field.
- func (u *AddWechatFriendLogUpsertBulk) ClearFindRequest() *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.ClearFindRequest()
- })
- }
- // SetFindResult sets the "find_result" field.
- func (u *AddWechatFriendLogUpsertBulk) SetFindResult(v map[string]interface{}) *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetFindResult(v)
- })
- }
- // UpdateFindResult sets the "find_result" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertBulk) UpdateFindResult() *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateFindResult()
- })
- }
- // ClearFindResult clears the value of the "find_result" field.
- func (u *AddWechatFriendLogUpsertBulk) ClearFindResult() *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.ClearFindResult()
- })
- }
- // SetIsCanAdd sets the "is_can_add" field.
- func (u *AddWechatFriendLogUpsertBulk) SetIsCanAdd(v int) *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetIsCanAdd(v)
- })
- }
- // AddIsCanAdd adds v to the "is_can_add" field.
- func (u *AddWechatFriendLogUpsertBulk) AddIsCanAdd(v int) *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.AddIsCanAdd(v)
- })
- }
- // UpdateIsCanAdd sets the "is_can_add" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertBulk) UpdateIsCanAdd() *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateIsCanAdd()
- })
- }
- // SetTaskCount sets the "task_count" field.
- func (u *AddWechatFriendLogUpsertBulk) SetTaskCount(v int) *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetTaskCount(v)
- })
- }
- // AddTaskCount adds v to the "task_count" field.
- func (u *AddWechatFriendLogUpsertBulk) AddTaskCount(v int) *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.AddTaskCount(v)
- })
- }
- // UpdateTaskCount sets the "task_count" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertBulk) UpdateTaskCount() *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateTaskCount()
- })
- }
- // SetTaskID sets the "task_id" field.
- func (u *AddWechatFriendLogUpsertBulk) SetTaskID(v int64) *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetTaskID(v)
- })
- }
- // AddTaskID adds v to the "task_id" field.
- func (u *AddWechatFriendLogUpsertBulk) AddTaskID(v int64) *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.AddTaskID(v)
- })
- }
- // UpdateTaskID sets the "task_id" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertBulk) UpdateTaskID() *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateTaskID()
- })
- }
- // SetAddRequest sets the "add_request" field.
- func (u *AddWechatFriendLogUpsertBulk) SetAddRequest(v map[string]interface{}) *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetAddRequest(v)
- })
- }
- // UpdateAddRequest sets the "add_request" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertBulk) UpdateAddRequest() *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateAddRequest()
- })
- }
- // ClearAddRequest clears the value of the "add_request" field.
- func (u *AddWechatFriendLogUpsertBulk) ClearAddRequest() *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.ClearAddRequest()
- })
- }
- // SetAddResult sets the "add_result" field.
- func (u *AddWechatFriendLogUpsertBulk) SetAddResult(v map[string]interface{}) *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetAddResult(v)
- })
- }
- // UpdateAddResult sets the "add_result" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertBulk) UpdateAddResult() *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateAddResult()
- })
- }
- // ClearAddResult clears the value of the "add_result" field.
- func (u *AddWechatFriendLogUpsertBulk) ClearAddResult() *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.ClearAddResult()
- })
- }
- // SetCreatedAt sets the "created_at" field.
- func (u *AddWechatFriendLogUpsertBulk) SetCreatedAt(v int64) *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetCreatedAt(v)
- })
- }
- // AddCreatedAt adds v to the "created_at" field.
- func (u *AddWechatFriendLogUpsertBulk) AddCreatedAt(v int64) *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.AddCreatedAt(v)
- })
- }
- // UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertBulk) UpdateCreatedAt() *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateCreatedAt()
- })
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *AddWechatFriendLogUpsertBulk) SetUpdatedAt(v int64) *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // AddUpdatedAt adds v to the "updated_at" field.
- func (u *AddWechatFriendLogUpsertBulk) AddUpdatedAt(v int64) *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.AddUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *AddWechatFriendLogUpsertBulk) UpdateUpdatedAt() *AddWechatFriendLogUpsertBulk {
- return u.Update(func(s *AddWechatFriendLogUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // Exec executes the query.
- func (u *AddWechatFriendLogUpsertBulk) 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 AddWechatFriendLogCreateBulk instead", i)
- }
- }
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for AddWechatFriendLogCreateBulk.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *AddWechatFriendLogUpsertBulk) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
|