| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- "github.com/Wei-Shaw/sub2api/ent/account"
- "github.com/Wei-Shaw/sub2api/ent/proxy"
- )
- // ProxyCreate is the builder for creating a Proxy entity.
- type ProxyCreate struct {
- config
- mutation *ProxyMutation
- hooks []Hook
- conflict []sql.ConflictOption
- }
- // SetCreatedAt sets the "created_at" field.
- func (_c *ProxyCreate) SetCreatedAt(v time.Time) *ProxyCreate {
- _c.mutation.SetCreatedAt(v)
- return _c
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (_c *ProxyCreate) SetNillableCreatedAt(v *time.Time) *ProxyCreate {
- if v != nil {
- _c.SetCreatedAt(*v)
- }
- return _c
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (_c *ProxyCreate) SetUpdatedAt(v time.Time) *ProxyCreate {
- _c.mutation.SetUpdatedAt(v)
- return _c
- }
- // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
- func (_c *ProxyCreate) SetNillableUpdatedAt(v *time.Time) *ProxyCreate {
- if v != nil {
- _c.SetUpdatedAt(*v)
- }
- return _c
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (_c *ProxyCreate) SetDeletedAt(v time.Time) *ProxyCreate {
- _c.mutation.SetDeletedAt(v)
- return _c
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (_c *ProxyCreate) SetNillableDeletedAt(v *time.Time) *ProxyCreate {
- if v != nil {
- _c.SetDeletedAt(*v)
- }
- return _c
- }
- // SetName sets the "name" field.
- func (_c *ProxyCreate) SetName(v string) *ProxyCreate {
- _c.mutation.SetName(v)
- return _c
- }
- // SetProtocol sets the "protocol" field.
- func (_c *ProxyCreate) SetProtocol(v string) *ProxyCreate {
- _c.mutation.SetProtocol(v)
- return _c
- }
- // SetHost sets the "host" field.
- func (_c *ProxyCreate) SetHost(v string) *ProxyCreate {
- _c.mutation.SetHost(v)
- return _c
- }
- // SetPort sets the "port" field.
- func (_c *ProxyCreate) SetPort(v int) *ProxyCreate {
- _c.mutation.SetPort(v)
- return _c
- }
- // SetUsername sets the "username" field.
- func (_c *ProxyCreate) SetUsername(v string) *ProxyCreate {
- _c.mutation.SetUsername(v)
- return _c
- }
- // SetNillableUsername sets the "username" field if the given value is not nil.
- func (_c *ProxyCreate) SetNillableUsername(v *string) *ProxyCreate {
- if v != nil {
- _c.SetUsername(*v)
- }
- return _c
- }
- // SetPassword sets the "password" field.
- func (_c *ProxyCreate) SetPassword(v string) *ProxyCreate {
- _c.mutation.SetPassword(v)
- return _c
- }
- // SetNillablePassword sets the "password" field if the given value is not nil.
- func (_c *ProxyCreate) SetNillablePassword(v *string) *ProxyCreate {
- if v != nil {
- _c.SetPassword(*v)
- }
- return _c
- }
- // SetStatus sets the "status" field.
- func (_c *ProxyCreate) SetStatus(v string) *ProxyCreate {
- _c.mutation.SetStatus(v)
- return _c
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (_c *ProxyCreate) SetNillableStatus(v *string) *ProxyCreate {
- if v != nil {
- _c.SetStatus(*v)
- }
- return _c
- }
- // SetExpiresAt sets the "expires_at" field.
- func (_c *ProxyCreate) SetExpiresAt(v time.Time) *ProxyCreate {
- _c.mutation.SetExpiresAt(v)
- return _c
- }
- // SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
- func (_c *ProxyCreate) SetNillableExpiresAt(v *time.Time) *ProxyCreate {
- if v != nil {
- _c.SetExpiresAt(*v)
- }
- return _c
- }
- // SetFallbackMode sets the "fallback_mode" field.
- func (_c *ProxyCreate) SetFallbackMode(v string) *ProxyCreate {
- _c.mutation.SetFallbackMode(v)
- return _c
- }
- // SetNillableFallbackMode sets the "fallback_mode" field if the given value is not nil.
- func (_c *ProxyCreate) SetNillableFallbackMode(v *string) *ProxyCreate {
- if v != nil {
- _c.SetFallbackMode(*v)
- }
- return _c
- }
- // SetBackupProxyID sets the "backup_proxy_id" field.
- func (_c *ProxyCreate) SetBackupProxyID(v int64) *ProxyCreate {
- _c.mutation.SetBackupProxyID(v)
- return _c
- }
- // SetNillableBackupProxyID sets the "backup_proxy_id" field if the given value is not nil.
- func (_c *ProxyCreate) SetNillableBackupProxyID(v *int64) *ProxyCreate {
- if v != nil {
- _c.SetBackupProxyID(*v)
- }
- return _c
- }
- // SetExpiryWarnDays sets the "expiry_warn_days" field.
- func (_c *ProxyCreate) SetExpiryWarnDays(v int) *ProxyCreate {
- _c.mutation.SetExpiryWarnDays(v)
- return _c
- }
- // SetNillableExpiryWarnDays sets the "expiry_warn_days" field if the given value is not nil.
- func (_c *ProxyCreate) SetNillableExpiryWarnDays(v *int) *ProxyCreate {
- if v != nil {
- _c.SetExpiryWarnDays(*v)
- }
- return _c
- }
- // AddAccountIDs adds the "accounts" edge to the Account entity by IDs.
- func (_c *ProxyCreate) AddAccountIDs(ids ...int64) *ProxyCreate {
- _c.mutation.AddAccountIDs(ids...)
- return _c
- }
- // AddAccounts adds the "accounts" edges to the Account entity.
- func (_c *ProxyCreate) AddAccounts(v ...*Account) *ProxyCreate {
- ids := make([]int64, len(v))
- for i := range v {
- ids[i] = v[i].ID
- }
- return _c.AddAccountIDs(ids...)
- }
- // AddPrimaryProxyIDs adds the "primary_proxies" edge to the Proxy entity by IDs.
- func (_c *ProxyCreate) AddPrimaryProxyIDs(ids ...int64) *ProxyCreate {
- _c.mutation.AddPrimaryProxyIDs(ids...)
- return _c
- }
- // AddPrimaryProxies adds the "primary_proxies" edges to the Proxy entity.
- func (_c *ProxyCreate) AddPrimaryProxies(v ...*Proxy) *ProxyCreate {
- ids := make([]int64, len(v))
- for i := range v {
- ids[i] = v[i].ID
- }
- return _c.AddPrimaryProxyIDs(ids...)
- }
- // SetBackupProxy sets the "backup_proxy" edge to the Proxy entity.
- func (_c *ProxyCreate) SetBackupProxy(v *Proxy) *ProxyCreate {
- return _c.SetBackupProxyID(v.ID)
- }
- // Mutation returns the ProxyMutation object of the builder.
- func (_c *ProxyCreate) Mutation() *ProxyMutation {
- return _c.mutation
- }
- // Save creates the Proxy in the database.
- func (_c *ProxyCreate) Save(ctx context.Context) (*Proxy, error) {
- if err := _c.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
- }
- // SaveX calls Save and panics if Save returns an error.
- func (_c *ProxyCreate) SaveX(ctx context.Context) *Proxy {
- v, err := _c.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (_c *ProxyCreate) Exec(ctx context.Context) error {
- _, err := _c.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_c *ProxyCreate) ExecX(ctx context.Context) {
- if err := _c.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (_c *ProxyCreate) defaults() error {
- if _, ok := _c.mutation.CreatedAt(); !ok {
- if proxy.DefaultCreatedAt == nil {
- return fmt.Errorf("ent: uninitialized proxy.DefaultCreatedAt (forgotten import ent/runtime?)")
- }
- v := proxy.DefaultCreatedAt()
- _c.mutation.SetCreatedAt(v)
- }
- if _, ok := _c.mutation.UpdatedAt(); !ok {
- if proxy.DefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized proxy.DefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := proxy.DefaultUpdatedAt()
- _c.mutation.SetUpdatedAt(v)
- }
- if _, ok := _c.mutation.Status(); !ok {
- v := proxy.DefaultStatus
- _c.mutation.SetStatus(v)
- }
- if _, ok := _c.mutation.FallbackMode(); !ok {
- v := proxy.DefaultFallbackMode
- _c.mutation.SetFallbackMode(v)
- }
- if _, ok := _c.mutation.ExpiryWarnDays(); !ok {
- v := proxy.DefaultExpiryWarnDays
- _c.mutation.SetExpiryWarnDays(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (_c *ProxyCreate) check() error {
- if _, ok := _c.mutation.CreatedAt(); !ok {
- return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Proxy.created_at"`)}
- }
- if _, ok := _c.mutation.UpdatedAt(); !ok {
- return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Proxy.updated_at"`)}
- }
- if _, ok := _c.mutation.Name(); !ok {
- return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Proxy.name"`)}
- }
- if v, ok := _c.mutation.Name(); ok {
- if err := proxy.NameValidator(v); err != nil {
- return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Proxy.name": %w`, err)}
- }
- }
- if _, ok := _c.mutation.Protocol(); !ok {
- return &ValidationError{Name: "protocol", err: errors.New(`ent: missing required field "Proxy.protocol"`)}
- }
- if v, ok := _c.mutation.Protocol(); ok {
- if err := proxy.ProtocolValidator(v); err != nil {
- return &ValidationError{Name: "protocol", err: fmt.Errorf(`ent: validator failed for field "Proxy.protocol": %w`, err)}
- }
- }
- if _, ok := _c.mutation.Host(); !ok {
- return &ValidationError{Name: "host", err: errors.New(`ent: missing required field "Proxy.host"`)}
- }
- if v, ok := _c.mutation.Host(); ok {
- if err := proxy.HostValidator(v); err != nil {
- return &ValidationError{Name: "host", err: fmt.Errorf(`ent: validator failed for field "Proxy.host": %w`, err)}
- }
- }
- if _, ok := _c.mutation.Port(); !ok {
- return &ValidationError{Name: "port", err: errors.New(`ent: missing required field "Proxy.port"`)}
- }
- if v, ok := _c.mutation.Username(); ok {
- if err := proxy.UsernameValidator(v); err != nil {
- return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "Proxy.username": %w`, err)}
- }
- }
- if v, ok := _c.mutation.Password(); ok {
- if err := proxy.PasswordValidator(v); err != nil {
- return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "Proxy.password": %w`, err)}
- }
- }
- if _, ok := _c.mutation.Status(); !ok {
- return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Proxy.status"`)}
- }
- if v, ok := _c.mutation.Status(); ok {
- if err := proxy.StatusValidator(v); err != nil {
- return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Proxy.status": %w`, err)}
- }
- }
- if _, ok := _c.mutation.FallbackMode(); !ok {
- return &ValidationError{Name: "fallback_mode", err: errors.New(`ent: missing required field "Proxy.fallback_mode"`)}
- }
- if v, ok := _c.mutation.FallbackMode(); ok {
- if err := proxy.FallbackModeValidator(v); err != nil {
- return &ValidationError{Name: "fallback_mode", err: fmt.Errorf(`ent: validator failed for field "Proxy.fallback_mode": %w`, err)}
- }
- }
- if _, ok := _c.mutation.ExpiryWarnDays(); !ok {
- return &ValidationError{Name: "expiry_warn_days", err: errors.New(`ent: missing required field "Proxy.expiry_warn_days"`)}
- }
- return nil
- }
- func (_c *ProxyCreate) sqlSave(ctx context.Context) (*Proxy, error) {
- if err := _c.check(); err != nil {
- return nil, err
- }
- _node, _spec := _c.createSpec()
- if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
- if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- id := _spec.ID.Value.(int64)
- _node.ID = int64(id)
- _c.mutation.id = &_node.ID
- _c.mutation.done = true
- return _node, nil
- }
- func (_c *ProxyCreate) createSpec() (*Proxy, *sqlgraph.CreateSpec) {
- var (
- _node = &Proxy{config: _c.config}
- _spec = sqlgraph.NewCreateSpec(proxy.Table, sqlgraph.NewFieldSpec(proxy.FieldID, field.TypeInt64))
- )
- _spec.OnConflict = _c.conflict
- if value, ok := _c.mutation.CreatedAt(); ok {
- _spec.SetField(proxy.FieldCreatedAt, field.TypeTime, value)
- _node.CreatedAt = value
- }
- if value, ok := _c.mutation.UpdatedAt(); ok {
- _spec.SetField(proxy.FieldUpdatedAt, field.TypeTime, value)
- _node.UpdatedAt = value
- }
- if value, ok := _c.mutation.DeletedAt(); ok {
- _spec.SetField(proxy.FieldDeletedAt, field.TypeTime, value)
- _node.DeletedAt = &value
- }
- if value, ok := _c.mutation.Name(); ok {
- _spec.SetField(proxy.FieldName, field.TypeString, value)
- _node.Name = value
- }
- if value, ok := _c.mutation.Protocol(); ok {
- _spec.SetField(proxy.FieldProtocol, field.TypeString, value)
- _node.Protocol = value
- }
- if value, ok := _c.mutation.Host(); ok {
- _spec.SetField(proxy.FieldHost, field.TypeString, value)
- _node.Host = value
- }
- if value, ok := _c.mutation.Port(); ok {
- _spec.SetField(proxy.FieldPort, field.TypeInt, value)
- _node.Port = value
- }
- if value, ok := _c.mutation.Username(); ok {
- _spec.SetField(proxy.FieldUsername, field.TypeString, value)
- _node.Username = &value
- }
- if value, ok := _c.mutation.Password(); ok {
- _spec.SetField(proxy.FieldPassword, field.TypeString, value)
- _node.Password = &value
- }
- if value, ok := _c.mutation.Status(); ok {
- _spec.SetField(proxy.FieldStatus, field.TypeString, value)
- _node.Status = value
- }
- if value, ok := _c.mutation.ExpiresAt(); ok {
- _spec.SetField(proxy.FieldExpiresAt, field.TypeTime, value)
- _node.ExpiresAt = &value
- }
- if value, ok := _c.mutation.FallbackMode(); ok {
- _spec.SetField(proxy.FieldFallbackMode, field.TypeString, value)
- _node.FallbackMode = value
- }
- if value, ok := _c.mutation.ExpiryWarnDays(); ok {
- _spec.SetField(proxy.FieldExpiryWarnDays, field.TypeInt, value)
- _node.ExpiryWarnDays = value
- }
- if nodes := _c.mutation.AccountsIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: true,
- Table: proxy.AccountsTable,
- Columns: []string{proxy.AccountsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges = append(_spec.Edges, edge)
- }
- if nodes := _c.mutation.PrimaryProxiesIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: true,
- Table: proxy.PrimaryProxiesTable,
- Columns: []string{proxy.PrimaryProxiesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(proxy.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges = append(_spec.Edges, edge)
- }
- if nodes := _c.mutation.BackupProxyIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: false,
- Table: proxy.BackupProxyTable,
- Columns: []string{proxy.BackupProxyColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(proxy.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _node.BackupProxyID = &nodes[0]
- _spec.Edges = append(_spec.Edges, edge)
- }
- return _node, _spec
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.Proxy.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.ProxyUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (_c *ProxyCreate) OnConflict(opts ...sql.ConflictOption) *ProxyUpsertOne {
- _c.conflict = opts
- return &ProxyUpsertOne{
- create: _c,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.Proxy.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (_c *ProxyCreate) OnConflictColumns(columns ...string) *ProxyUpsertOne {
- _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
- return &ProxyUpsertOne{
- create: _c,
- }
- }
- type (
- // ProxyUpsertOne is the builder for "upsert"-ing
- // one Proxy node.
- ProxyUpsertOne struct {
- create *ProxyCreate
- }
- // ProxyUpsert is the "OnConflict" setter.
- ProxyUpsert struct {
- *sql.UpdateSet
- }
- )
- // SetUpdatedAt sets the "updated_at" field.
- func (u *ProxyUpsert) SetUpdatedAt(v time.Time) *ProxyUpsert {
- u.Set(proxy.FieldUpdatedAt, v)
- return u
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *ProxyUpsert) UpdateUpdatedAt() *ProxyUpsert {
- u.SetExcluded(proxy.FieldUpdatedAt)
- return u
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *ProxyUpsert) SetDeletedAt(v time.Time) *ProxyUpsert {
- u.Set(proxy.FieldDeletedAt, v)
- return u
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *ProxyUpsert) UpdateDeletedAt() *ProxyUpsert {
- u.SetExcluded(proxy.FieldDeletedAt)
- return u
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *ProxyUpsert) ClearDeletedAt() *ProxyUpsert {
- u.SetNull(proxy.FieldDeletedAt)
- return u
- }
- // SetName sets the "name" field.
- func (u *ProxyUpsert) SetName(v string) *ProxyUpsert {
- u.Set(proxy.FieldName, v)
- return u
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *ProxyUpsert) UpdateName() *ProxyUpsert {
- u.SetExcluded(proxy.FieldName)
- return u
- }
- // SetProtocol sets the "protocol" field.
- func (u *ProxyUpsert) SetProtocol(v string) *ProxyUpsert {
- u.Set(proxy.FieldProtocol, v)
- return u
- }
- // UpdateProtocol sets the "protocol" field to the value that was provided on create.
- func (u *ProxyUpsert) UpdateProtocol() *ProxyUpsert {
- u.SetExcluded(proxy.FieldProtocol)
- return u
- }
- // SetHost sets the "host" field.
- func (u *ProxyUpsert) SetHost(v string) *ProxyUpsert {
- u.Set(proxy.FieldHost, v)
- return u
- }
- // UpdateHost sets the "host" field to the value that was provided on create.
- func (u *ProxyUpsert) UpdateHost() *ProxyUpsert {
- u.SetExcluded(proxy.FieldHost)
- return u
- }
- // SetPort sets the "port" field.
- func (u *ProxyUpsert) SetPort(v int) *ProxyUpsert {
- u.Set(proxy.FieldPort, v)
- return u
- }
- // UpdatePort sets the "port" field to the value that was provided on create.
- func (u *ProxyUpsert) UpdatePort() *ProxyUpsert {
- u.SetExcluded(proxy.FieldPort)
- return u
- }
- // AddPort adds v to the "port" field.
- func (u *ProxyUpsert) AddPort(v int) *ProxyUpsert {
- u.Add(proxy.FieldPort, v)
- return u
- }
- // SetUsername sets the "username" field.
- func (u *ProxyUpsert) SetUsername(v string) *ProxyUpsert {
- u.Set(proxy.FieldUsername, v)
- return u
- }
- // UpdateUsername sets the "username" field to the value that was provided on create.
- func (u *ProxyUpsert) UpdateUsername() *ProxyUpsert {
- u.SetExcluded(proxy.FieldUsername)
- return u
- }
- // ClearUsername clears the value of the "username" field.
- func (u *ProxyUpsert) ClearUsername() *ProxyUpsert {
- u.SetNull(proxy.FieldUsername)
- return u
- }
- // SetPassword sets the "password" field.
- func (u *ProxyUpsert) SetPassword(v string) *ProxyUpsert {
- u.Set(proxy.FieldPassword, v)
- return u
- }
- // UpdatePassword sets the "password" field to the value that was provided on create.
- func (u *ProxyUpsert) UpdatePassword() *ProxyUpsert {
- u.SetExcluded(proxy.FieldPassword)
- return u
- }
- // ClearPassword clears the value of the "password" field.
- func (u *ProxyUpsert) ClearPassword() *ProxyUpsert {
- u.SetNull(proxy.FieldPassword)
- return u
- }
- // SetStatus sets the "status" field.
- func (u *ProxyUpsert) SetStatus(v string) *ProxyUpsert {
- u.Set(proxy.FieldStatus, v)
- return u
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *ProxyUpsert) UpdateStatus() *ProxyUpsert {
- u.SetExcluded(proxy.FieldStatus)
- return u
- }
- // SetExpiresAt sets the "expires_at" field.
- func (u *ProxyUpsert) SetExpiresAt(v time.Time) *ProxyUpsert {
- u.Set(proxy.FieldExpiresAt, v)
- return u
- }
- // UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
- func (u *ProxyUpsert) UpdateExpiresAt() *ProxyUpsert {
- u.SetExcluded(proxy.FieldExpiresAt)
- return u
- }
- // ClearExpiresAt clears the value of the "expires_at" field.
- func (u *ProxyUpsert) ClearExpiresAt() *ProxyUpsert {
- u.SetNull(proxy.FieldExpiresAt)
- return u
- }
- // SetFallbackMode sets the "fallback_mode" field.
- func (u *ProxyUpsert) SetFallbackMode(v string) *ProxyUpsert {
- u.Set(proxy.FieldFallbackMode, v)
- return u
- }
- // UpdateFallbackMode sets the "fallback_mode" field to the value that was provided on create.
- func (u *ProxyUpsert) UpdateFallbackMode() *ProxyUpsert {
- u.SetExcluded(proxy.FieldFallbackMode)
- return u
- }
- // SetBackupProxyID sets the "backup_proxy_id" field.
- func (u *ProxyUpsert) SetBackupProxyID(v int64) *ProxyUpsert {
- u.Set(proxy.FieldBackupProxyID, v)
- return u
- }
- // UpdateBackupProxyID sets the "backup_proxy_id" field to the value that was provided on create.
- func (u *ProxyUpsert) UpdateBackupProxyID() *ProxyUpsert {
- u.SetExcluded(proxy.FieldBackupProxyID)
- return u
- }
- // ClearBackupProxyID clears the value of the "backup_proxy_id" field.
- func (u *ProxyUpsert) ClearBackupProxyID() *ProxyUpsert {
- u.SetNull(proxy.FieldBackupProxyID)
- return u
- }
- // SetExpiryWarnDays sets the "expiry_warn_days" field.
- func (u *ProxyUpsert) SetExpiryWarnDays(v int) *ProxyUpsert {
- u.Set(proxy.FieldExpiryWarnDays, v)
- return u
- }
- // UpdateExpiryWarnDays sets the "expiry_warn_days" field to the value that was provided on create.
- func (u *ProxyUpsert) UpdateExpiryWarnDays() *ProxyUpsert {
- u.SetExcluded(proxy.FieldExpiryWarnDays)
- return u
- }
- // AddExpiryWarnDays adds v to the "expiry_warn_days" field.
- func (u *ProxyUpsert) AddExpiryWarnDays(v int) *ProxyUpsert {
- u.Add(proxy.FieldExpiryWarnDays, v)
- return u
- }
- // UpdateNewValues updates the mutable fields using the new values that were set on create.
- // Using this option is equivalent to using:
- //
- // client.Proxy.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // ).
- // Exec(ctx)
- func (u *ProxyUpsertOne) UpdateNewValues() *ProxyUpsertOne {
- 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.CreatedAt(); exists {
- s.SetIgnore(proxy.FieldCreatedAt)
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.Proxy.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *ProxyUpsertOne) Ignore() *ProxyUpsertOne {
- 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 *ProxyUpsertOne) DoNothing() *ProxyUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the ProxyCreate.OnConflict
- // documentation for more info.
- func (u *ProxyUpsertOne) Update(set func(*ProxyUpsert)) *ProxyUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&ProxyUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *ProxyUpsertOne) SetUpdatedAt(v time.Time) *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *ProxyUpsertOne) UpdateUpdatedAt() *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *ProxyUpsertOne) SetDeletedAt(v time.Time) *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *ProxyUpsertOne) UpdateDeletedAt() *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *ProxyUpsertOne) ClearDeletedAt() *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetName sets the "name" field.
- func (u *ProxyUpsertOne) SetName(v string) *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.SetName(v)
- })
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *ProxyUpsertOne) UpdateName() *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateName()
- })
- }
- // SetProtocol sets the "protocol" field.
- func (u *ProxyUpsertOne) SetProtocol(v string) *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.SetProtocol(v)
- })
- }
- // UpdateProtocol sets the "protocol" field to the value that was provided on create.
- func (u *ProxyUpsertOne) UpdateProtocol() *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateProtocol()
- })
- }
- // SetHost sets the "host" field.
- func (u *ProxyUpsertOne) SetHost(v string) *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.SetHost(v)
- })
- }
- // UpdateHost sets the "host" field to the value that was provided on create.
- func (u *ProxyUpsertOne) UpdateHost() *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateHost()
- })
- }
- // SetPort sets the "port" field.
- func (u *ProxyUpsertOne) SetPort(v int) *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.SetPort(v)
- })
- }
- // AddPort adds v to the "port" field.
- func (u *ProxyUpsertOne) AddPort(v int) *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.AddPort(v)
- })
- }
- // UpdatePort sets the "port" field to the value that was provided on create.
- func (u *ProxyUpsertOne) UpdatePort() *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdatePort()
- })
- }
- // SetUsername sets the "username" field.
- func (u *ProxyUpsertOne) SetUsername(v string) *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.SetUsername(v)
- })
- }
- // UpdateUsername sets the "username" field to the value that was provided on create.
- func (u *ProxyUpsertOne) UpdateUsername() *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateUsername()
- })
- }
- // ClearUsername clears the value of the "username" field.
- func (u *ProxyUpsertOne) ClearUsername() *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.ClearUsername()
- })
- }
- // SetPassword sets the "password" field.
- func (u *ProxyUpsertOne) SetPassword(v string) *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.SetPassword(v)
- })
- }
- // UpdatePassword sets the "password" field to the value that was provided on create.
- func (u *ProxyUpsertOne) UpdatePassword() *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdatePassword()
- })
- }
- // ClearPassword clears the value of the "password" field.
- func (u *ProxyUpsertOne) ClearPassword() *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.ClearPassword()
- })
- }
- // SetStatus sets the "status" field.
- func (u *ProxyUpsertOne) SetStatus(v string) *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.SetStatus(v)
- })
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *ProxyUpsertOne) UpdateStatus() *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateStatus()
- })
- }
- // SetExpiresAt sets the "expires_at" field.
- func (u *ProxyUpsertOne) SetExpiresAt(v time.Time) *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.SetExpiresAt(v)
- })
- }
- // UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
- func (u *ProxyUpsertOne) UpdateExpiresAt() *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateExpiresAt()
- })
- }
- // ClearExpiresAt clears the value of the "expires_at" field.
- func (u *ProxyUpsertOne) ClearExpiresAt() *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.ClearExpiresAt()
- })
- }
- // SetFallbackMode sets the "fallback_mode" field.
- func (u *ProxyUpsertOne) SetFallbackMode(v string) *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.SetFallbackMode(v)
- })
- }
- // UpdateFallbackMode sets the "fallback_mode" field to the value that was provided on create.
- func (u *ProxyUpsertOne) UpdateFallbackMode() *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateFallbackMode()
- })
- }
- // SetBackupProxyID sets the "backup_proxy_id" field.
- func (u *ProxyUpsertOne) SetBackupProxyID(v int64) *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.SetBackupProxyID(v)
- })
- }
- // UpdateBackupProxyID sets the "backup_proxy_id" field to the value that was provided on create.
- func (u *ProxyUpsertOne) UpdateBackupProxyID() *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateBackupProxyID()
- })
- }
- // ClearBackupProxyID clears the value of the "backup_proxy_id" field.
- func (u *ProxyUpsertOne) ClearBackupProxyID() *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.ClearBackupProxyID()
- })
- }
- // SetExpiryWarnDays sets the "expiry_warn_days" field.
- func (u *ProxyUpsertOne) SetExpiryWarnDays(v int) *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.SetExpiryWarnDays(v)
- })
- }
- // AddExpiryWarnDays adds v to the "expiry_warn_days" field.
- func (u *ProxyUpsertOne) AddExpiryWarnDays(v int) *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.AddExpiryWarnDays(v)
- })
- }
- // UpdateExpiryWarnDays sets the "expiry_warn_days" field to the value that was provided on create.
- func (u *ProxyUpsertOne) UpdateExpiryWarnDays() *ProxyUpsertOne {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateExpiryWarnDays()
- })
- }
- // Exec executes the query.
- func (u *ProxyUpsertOne) Exec(ctx context.Context) error {
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for ProxyCreate.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *ProxyUpsertOne) 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 *ProxyUpsertOne) 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 *ProxyUpsertOne) IDX(ctx context.Context) int64 {
- id, err := u.ID(ctx)
- if err != nil {
- panic(err)
- }
- return id
- }
- // ProxyCreateBulk is the builder for creating many Proxy entities in bulk.
- type ProxyCreateBulk struct {
- config
- err error
- builders []*ProxyCreate
- conflict []sql.ConflictOption
- }
- // Save creates the Proxy entities in the database.
- func (_c *ProxyCreateBulk) Save(ctx context.Context) ([]*Proxy, error) {
- if _c.err != nil {
- return nil, _c.err
- }
- specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
- nodes := make([]*Proxy, len(_c.builders))
- mutators := make([]Mutator, len(_c.builders))
- for i := range _c.builders {
- func(i int, root context.Context) {
- builder := _c.builders[i]
- builder.defaults()
- var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
- mutation, ok := m.(*ProxyMutation)
- 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, _c.builders[i+1].mutation)
- } else {
- spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
- spec.OnConflict = _c.conflict
- // Invoke the actual operation on the latest mutation in the chain.
- if err = sqlgraph.BatchCreate(ctx, _c.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 {
- 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, _c.builders[0].mutation); err != nil {
- return nil, err
- }
- }
- return nodes, nil
- }
- // SaveX is like Save, but panics if an error occurs.
- func (_c *ProxyCreateBulk) SaveX(ctx context.Context) []*Proxy {
- v, err := _c.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (_c *ProxyCreateBulk) Exec(ctx context.Context) error {
- _, err := _c.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_c *ProxyCreateBulk) ExecX(ctx context.Context) {
- if err := _c.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.Proxy.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.ProxyUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (_c *ProxyCreateBulk) OnConflict(opts ...sql.ConflictOption) *ProxyUpsertBulk {
- _c.conflict = opts
- return &ProxyUpsertBulk{
- create: _c,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.Proxy.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (_c *ProxyCreateBulk) OnConflictColumns(columns ...string) *ProxyUpsertBulk {
- _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
- return &ProxyUpsertBulk{
- create: _c,
- }
- }
- // ProxyUpsertBulk is the builder for "upsert"-ing
- // a bulk of Proxy nodes.
- type ProxyUpsertBulk struct {
- create *ProxyCreateBulk
- }
- // UpdateNewValues updates the mutable fields using the new values that
- // were set on create. Using this option is equivalent to using:
- //
- // client.Proxy.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // ).
- // Exec(ctx)
- func (u *ProxyUpsertBulk) UpdateNewValues() *ProxyUpsertBulk {
- 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.CreatedAt(); exists {
- s.SetIgnore(proxy.FieldCreatedAt)
- }
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.Proxy.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *ProxyUpsertBulk) Ignore() *ProxyUpsertBulk {
- 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 *ProxyUpsertBulk) DoNothing() *ProxyUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the ProxyCreateBulk.OnConflict
- // documentation for more info.
- func (u *ProxyUpsertBulk) Update(set func(*ProxyUpsert)) *ProxyUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&ProxyUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *ProxyUpsertBulk) SetUpdatedAt(v time.Time) *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *ProxyUpsertBulk) UpdateUpdatedAt() *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *ProxyUpsertBulk) SetDeletedAt(v time.Time) *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *ProxyUpsertBulk) UpdateDeletedAt() *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *ProxyUpsertBulk) ClearDeletedAt() *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetName sets the "name" field.
- func (u *ProxyUpsertBulk) SetName(v string) *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.SetName(v)
- })
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *ProxyUpsertBulk) UpdateName() *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateName()
- })
- }
- // SetProtocol sets the "protocol" field.
- func (u *ProxyUpsertBulk) SetProtocol(v string) *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.SetProtocol(v)
- })
- }
- // UpdateProtocol sets the "protocol" field to the value that was provided on create.
- func (u *ProxyUpsertBulk) UpdateProtocol() *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateProtocol()
- })
- }
- // SetHost sets the "host" field.
- func (u *ProxyUpsertBulk) SetHost(v string) *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.SetHost(v)
- })
- }
- // UpdateHost sets the "host" field to the value that was provided on create.
- func (u *ProxyUpsertBulk) UpdateHost() *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateHost()
- })
- }
- // SetPort sets the "port" field.
- func (u *ProxyUpsertBulk) SetPort(v int) *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.SetPort(v)
- })
- }
- // AddPort adds v to the "port" field.
- func (u *ProxyUpsertBulk) AddPort(v int) *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.AddPort(v)
- })
- }
- // UpdatePort sets the "port" field to the value that was provided on create.
- func (u *ProxyUpsertBulk) UpdatePort() *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdatePort()
- })
- }
- // SetUsername sets the "username" field.
- func (u *ProxyUpsertBulk) SetUsername(v string) *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.SetUsername(v)
- })
- }
- // UpdateUsername sets the "username" field to the value that was provided on create.
- func (u *ProxyUpsertBulk) UpdateUsername() *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateUsername()
- })
- }
- // ClearUsername clears the value of the "username" field.
- func (u *ProxyUpsertBulk) ClearUsername() *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.ClearUsername()
- })
- }
- // SetPassword sets the "password" field.
- func (u *ProxyUpsertBulk) SetPassword(v string) *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.SetPassword(v)
- })
- }
- // UpdatePassword sets the "password" field to the value that was provided on create.
- func (u *ProxyUpsertBulk) UpdatePassword() *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdatePassword()
- })
- }
- // ClearPassword clears the value of the "password" field.
- func (u *ProxyUpsertBulk) ClearPassword() *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.ClearPassword()
- })
- }
- // SetStatus sets the "status" field.
- func (u *ProxyUpsertBulk) SetStatus(v string) *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.SetStatus(v)
- })
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *ProxyUpsertBulk) UpdateStatus() *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateStatus()
- })
- }
- // SetExpiresAt sets the "expires_at" field.
- func (u *ProxyUpsertBulk) SetExpiresAt(v time.Time) *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.SetExpiresAt(v)
- })
- }
- // UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
- func (u *ProxyUpsertBulk) UpdateExpiresAt() *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateExpiresAt()
- })
- }
- // ClearExpiresAt clears the value of the "expires_at" field.
- func (u *ProxyUpsertBulk) ClearExpiresAt() *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.ClearExpiresAt()
- })
- }
- // SetFallbackMode sets the "fallback_mode" field.
- func (u *ProxyUpsertBulk) SetFallbackMode(v string) *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.SetFallbackMode(v)
- })
- }
- // UpdateFallbackMode sets the "fallback_mode" field to the value that was provided on create.
- func (u *ProxyUpsertBulk) UpdateFallbackMode() *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateFallbackMode()
- })
- }
- // SetBackupProxyID sets the "backup_proxy_id" field.
- func (u *ProxyUpsertBulk) SetBackupProxyID(v int64) *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.SetBackupProxyID(v)
- })
- }
- // UpdateBackupProxyID sets the "backup_proxy_id" field to the value that was provided on create.
- func (u *ProxyUpsertBulk) UpdateBackupProxyID() *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateBackupProxyID()
- })
- }
- // ClearBackupProxyID clears the value of the "backup_proxy_id" field.
- func (u *ProxyUpsertBulk) ClearBackupProxyID() *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.ClearBackupProxyID()
- })
- }
- // SetExpiryWarnDays sets the "expiry_warn_days" field.
- func (u *ProxyUpsertBulk) SetExpiryWarnDays(v int) *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.SetExpiryWarnDays(v)
- })
- }
- // AddExpiryWarnDays adds v to the "expiry_warn_days" field.
- func (u *ProxyUpsertBulk) AddExpiryWarnDays(v int) *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.AddExpiryWarnDays(v)
- })
- }
- // UpdateExpiryWarnDays sets the "expiry_warn_days" field to the value that was provided on create.
- func (u *ProxyUpsertBulk) UpdateExpiryWarnDays() *ProxyUpsertBulk {
- return u.Update(func(s *ProxyUpsert) {
- s.UpdateExpiryWarnDays()
- })
- }
- // Exec executes the query.
- func (u *ProxyUpsertBulk) 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 ProxyCreateBulk instead", i)
- }
- }
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for ProxyCreateBulk.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *ProxyUpsertBulk) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
|