Something went wrong. Try again.
Self-hosted file management and sharing system, supports multiple storage providers. forked from tdvorak.tngl.sh/cloudreve
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181// 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/cloudreve/Cloudreve/v4/ent/node" "github.com/cloudreve/Cloudreve/v4/ent/storagepolicy" "github.com/cloudreve/Cloudreve/v4/inventory/types" "github.com/cloudreve/Cloudreve/v4/pkg/boolset")
// NodeCreate is the builder for creating a Node entity.type NodeCreate struct { config mutation *NodeMutation hooks []Hook conflict []sql.ConflictOption}
// SetCreatedAt sets the "created_at" field.func (nc *NodeCreate) SetCreatedAt(t time.Time) *NodeCreate { nc.mutation.SetCreatedAt(t) return nc}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.func (nc *NodeCreate) SetNillableCreatedAt(t *time.Time) *NodeCreate { if t != nil { nc.SetCreatedAt(*t) } return nc}
// SetUpdatedAt sets the "updated_at" field.func (nc *NodeCreate) SetUpdatedAt(t time.Time) *NodeCreate { nc.mutation.SetUpdatedAt(t) return nc}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.func (nc *NodeCreate) SetNillableUpdatedAt(t *time.Time) *NodeCreate { if t != nil { nc.SetUpdatedAt(*t) } return nc}
// SetDeletedAt sets the "deleted_at" field.func (nc *NodeCreate) SetDeletedAt(t time.Time) *NodeCreate { nc.mutation.SetDeletedAt(t) return nc}
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.func (nc *NodeCreate) SetNillableDeletedAt(t *time.Time) *NodeCreate { if t != nil { nc.SetDeletedAt(*t) } return nc}
// SetStatus sets the "status" field.func (nc *NodeCreate) SetStatus(n node.Status) *NodeCreate { nc.mutation.SetStatus(n) return nc}
// SetName sets the "name" field.func (nc *NodeCreate) SetName(s string) *NodeCreate { nc.mutation.SetName(s) return nc}
// SetType sets the "type" field.func (nc *NodeCreate) SetType(n node.Type) *NodeCreate { nc.mutation.SetType(n) return nc}
// SetServer sets the "server" field.func (nc *NodeCreate) SetServer(s string) *NodeCreate { nc.mutation.SetServer(s) return nc}
// SetNillableServer sets the "server" field if the given value is not nil.func (nc *NodeCreate) SetNillableServer(s *string) *NodeCreate { if s != nil { nc.SetServer(*s) } return nc}
// SetSlaveKey sets the "slave_key" field.func (nc *NodeCreate) SetSlaveKey(s string) *NodeCreate { nc.mutation.SetSlaveKey(s) return nc}
// SetNillableSlaveKey sets the "slave_key" field if the given value is not nil.func (nc *NodeCreate) SetNillableSlaveKey(s *string) *NodeCreate { if s != nil { nc.SetSlaveKey(*s) } return nc}
// SetCapabilities sets the "capabilities" field.func (nc *NodeCreate) SetCapabilities(bs *boolset.BooleanSet) *NodeCreate { nc.mutation.SetCapabilities(bs) return nc}
// SetSettings sets the "settings" field.func (nc *NodeCreate) SetSettings(ts *types.NodeSetting) *NodeCreate { nc.mutation.SetSettings(ts) return nc}
// SetWeight sets the "weight" field.func (nc *NodeCreate) SetWeight(i int) *NodeCreate { nc.mutation.SetWeight(i) return nc}
// SetNillableWeight sets the "weight" field if the given value is not nil.func (nc *NodeCreate) SetNillableWeight(i *int) *NodeCreate { if i != nil { nc.SetWeight(*i) } return nc}
// AddStoragePolicyIDs adds the "storage_policy" edge to the StoragePolicy entity by IDs.func (nc *NodeCreate) AddStoragePolicyIDs(ids ...int) *NodeCreate { nc.mutation.AddStoragePolicyIDs(ids...) return nc}
// AddStoragePolicy adds the "storage_policy" edges to the StoragePolicy entity.func (nc *NodeCreate) AddStoragePolicy(s ...*StoragePolicy) *NodeCreate { ids := make([]int, len(s)) for i := range s { ids[i] = s[i].ID } return nc.AddStoragePolicyIDs(ids...)}
// Mutation returns the NodeMutation object of the builder.func (nc *NodeCreate) Mutation() *NodeMutation { return nc.mutation}
// Save creates the Node in the database.func (nc *NodeCreate) Save(ctx context.Context) (*Node, error) { if err := nc.defaults(); err != nil { return nil, err } return withHooks(ctx, nc.sqlSave, nc.mutation, nc.hooks)}
// SaveX calls Save and panics if Save returns an error.func (nc *NodeCreate) SaveX(ctx context.Context) *Node { v, err := nc.Save(ctx) if err != nil { panic(err) } return v}
// Exec executes the query.func (nc *NodeCreate) Exec(ctx context.Context) error { _, err := nc.Save(ctx) return err}
// ExecX is like Exec, but panics if an error occurs.func (nc *NodeCreate) ExecX(ctx context.Context) { if err := nc.Exec(ctx); err != nil { panic(err) }}
// defaults sets the default values of the builder before save.func (nc *NodeCreate) defaults() error { if _, ok := nc.mutation.CreatedAt(); !ok { if node.DefaultCreatedAt == nil { return fmt.Errorf("ent: uninitialized node.DefaultCreatedAt (forgotten import ent/runtime?)") } v := node.DefaultCreatedAt() nc.mutation.SetCreatedAt(v) } if _, ok := nc.mutation.UpdatedAt(); !ok { if node.DefaultUpdatedAt == nil { return fmt.Errorf("ent: uninitialized node.DefaultUpdatedAt (forgotten import ent/runtime?)") } v := node.DefaultUpdatedAt() nc.mutation.SetUpdatedAt(v) } if _, ok := nc.mutation.Settings(); !ok { v := node.DefaultSettings nc.mutation.SetSettings(v) } if _, ok := nc.mutation.Weight(); !ok { v := node.DefaultWeight nc.mutation.SetWeight(v) } return nil}
// check runs all checks and user-defined validators on the builder.func (nc *NodeCreate) check() error { if _, ok := nc.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Node.created_at"`)} } if _, ok := nc.mutation.UpdatedAt(); !ok { return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Node.updated_at"`)} } if _, ok := nc.mutation.Status(); !ok { return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Node.status"`)} } if v, ok := nc.mutation.Status(); ok { if err := node.StatusValidator(v); err != nil { return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Node.status": %w`, err)} } } if _, ok := nc.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Node.name"`)} } if _, ok := nc.mutation.GetType(); !ok { return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Node.type"`)} } if v, ok := nc.mutation.GetType(); ok { if err := node.TypeValidator(v); err != nil { return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Node.type": %w`, err)} } } if _, ok := nc.mutation.Capabilities(); !ok { return &ValidationError{Name: "capabilities", err: errors.New(`ent: missing required field "Node.capabilities"`)} } if _, ok := nc.mutation.Weight(); !ok { return &ValidationError{Name: "weight", err: errors.New(`ent: missing required field "Node.weight"`)} } return nil}
func (nc *NodeCreate) sqlSave(ctx context.Context) (*Node, error) { if err := nc.check(); err != nil { return nil, err } _node, _spec := nc.createSpec() if err := sqlgraph.CreateNode(ctx, nc.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 = int(id) nc.mutation.id = &_node.ID nc.mutation.done = true return _node, nil}
func (nc *NodeCreate) createSpec() (*Node, *sqlgraph.CreateSpec) { var ( _node = &Node{config: nc.config} _spec = sqlgraph.NewCreateSpec(node.Table, sqlgraph.NewFieldSpec(node.FieldID, field.TypeInt)) )
if id, ok := nc.mutation.ID(); ok { _node.ID = id id64 := int64(id) _spec.ID.Value = id64 }
_spec.OnConflict = nc.conflict if value, ok := nc.mutation.CreatedAt(); ok { _spec.SetField(node.FieldCreatedAt, field.TypeTime, value) _node.CreatedAt = value } if value, ok := nc.mutation.UpdatedAt(); ok { _spec.SetField(node.FieldUpdatedAt, field.TypeTime, value) _node.UpdatedAt = value } if value, ok := nc.mutation.DeletedAt(); ok { _spec.SetField(node.FieldDeletedAt, field.TypeTime, value) _node.DeletedAt = &value } if value, ok := nc.mutation.Status(); ok { _spec.SetField(node.FieldStatus, field.TypeEnum, value) _node.Status = value } if value, ok := nc.mutation.Name(); ok { _spec.SetField(node.FieldName, field.TypeString, value) _node.Name = value } if value, ok := nc.mutation.GetType(); ok { _spec.SetField(node.FieldType, field.TypeEnum, value) _node.Type = value } if value, ok := nc.mutation.Server(); ok { _spec.SetField(node.FieldServer, field.TypeString, value) _node.Server = value } if value, ok := nc.mutation.SlaveKey(); ok { _spec.SetField(node.FieldSlaveKey, field.TypeString, value) _node.SlaveKey = value } if value, ok := nc.mutation.Capabilities(); ok { _spec.SetField(node.FieldCapabilities, field.TypeBytes, value) _node.Capabilities = value } if value, ok := nc.mutation.Settings(); ok { _spec.SetField(node.FieldSettings, field.TypeJSON, value) _node.Settings = value } if value, ok := nc.mutation.Weight(); ok { _spec.SetField(node.FieldWeight, field.TypeInt, value) _node.Weight = value } if nodes := nc.mutation.StoragePolicyIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: node.StoragePolicyTable, Columns: []string{node.StoragePolicyColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(storagepolicy.FieldID, field.TypeInt), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _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.Node.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.NodeUpsert) {// SetCreatedAt(v+v).// }).// Exec(ctx)func (nc *NodeCreate) OnConflict(opts ...sql.ConflictOption) *NodeUpsertOne { nc.conflict = opts return &NodeUpsertOne{ create: nc, }}
// OnConflictColumns calls `OnConflict` and configures the columns// as conflict target. Using this option is equivalent to using://// client.Node.Create().// OnConflict(sql.ConflictColumns(columns...)).// Exec(ctx)func (nc *NodeCreate) OnConflictColumns(columns ...string) *NodeUpsertOne { nc.conflict = append(nc.conflict, sql.ConflictColumns(columns...)) return &NodeUpsertOne{ create: nc, }}
type ( // NodeUpsertOne is the builder for "upsert"-ing // one Node node. NodeUpsertOne struct { create *NodeCreate }
// NodeUpsert is the "OnConflict" setter. NodeUpsert struct { *sql.UpdateSet })
// SetUpdatedAt sets the "updated_at" field.func (u *NodeUpsert) SetUpdatedAt(v time.Time) *NodeUpsert { u.Set(node.FieldUpdatedAt, v) return u}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.func (u *NodeUpsert) UpdateUpdatedAt() *NodeUpsert { u.SetExcluded(node.FieldUpdatedAt) return u}
// SetDeletedAt sets the "deleted_at" field.func (u *NodeUpsert) SetDeletedAt(v time.Time) *NodeUpsert { u.Set(node.FieldDeletedAt, v) return u}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.func (u *NodeUpsert) UpdateDeletedAt() *NodeUpsert { u.SetExcluded(node.FieldDeletedAt) return u}
// ClearDeletedAt clears the value of the "deleted_at" field.func (u *NodeUpsert) ClearDeletedAt() *NodeUpsert { u.SetNull(node.FieldDeletedAt) return u}
// SetStatus sets the "status" field.func (u *NodeUpsert) SetStatus(v node.Status) *NodeUpsert { u.Set(node.FieldStatus, v) return u}
// UpdateStatus sets the "status" field to the value that was provided on create.func (u *NodeUpsert) UpdateStatus() *NodeUpsert { u.SetExcluded(node.FieldStatus) return u}
// SetName sets the "name" field.func (u *NodeUpsert) SetName(v string) *NodeUpsert { u.Set(node.FieldName, v) return u}
// UpdateName sets the "name" field to the value that was provided on create.func (u *NodeUpsert) UpdateName() *NodeUpsert { u.SetExcluded(node.FieldName) return u}
// SetType sets the "type" field.func (u *NodeUpsert) SetType(v node.Type) *NodeUpsert { u.Set(node.FieldType, v) return u}
// UpdateType sets the "type" field to the value that was provided on create.func (u *NodeUpsert) UpdateType() *NodeUpsert { u.SetExcluded(node.FieldType) return u}
// SetServer sets the "server" field.func (u *NodeUpsert) SetServer(v string) *NodeUpsert { u.Set(node.FieldServer, v) return u}
// UpdateServer sets the "server" field to the value that was provided on create.func (u *NodeUpsert) UpdateServer() *NodeUpsert { u.SetExcluded(node.FieldServer) return u}
// ClearServer clears the value of the "server" field.func (u *NodeUpsert) ClearServer() *NodeUpsert { u.SetNull(node.FieldServer) return u}
// SetSlaveKey sets the "slave_key" field.func (u *NodeUpsert) SetSlaveKey(v string) *NodeUpsert { u.Set(node.FieldSlaveKey, v) return u}
// UpdateSlaveKey sets the "slave_key" field to the value that was provided on create.func (u *NodeUpsert) UpdateSlaveKey() *NodeUpsert { u.SetExcluded(node.FieldSlaveKey) return u}
// ClearSlaveKey clears the value of the "slave_key" field.func (u *NodeUpsert) ClearSlaveKey() *NodeUpsert { u.SetNull(node.FieldSlaveKey) return u}
// SetCapabilities sets the "capabilities" field.func (u *NodeUpsert) SetCapabilities(v *boolset.BooleanSet) *NodeUpsert { u.Set(node.FieldCapabilities, v) return u}
// UpdateCapabilities sets the "capabilities" field to the value that was provided on create.func (u *NodeUpsert) UpdateCapabilities() *NodeUpsert { u.SetExcluded(node.FieldCapabilities) return u}
// SetSettings sets the "settings" field.func (u *NodeUpsert) SetSettings(v *types.NodeSetting) *NodeUpsert { u.Set(node.FieldSettings, v) return u}
// UpdateSettings sets the "settings" field to the value that was provided on create.func (u *NodeUpsert) UpdateSettings() *NodeUpsert { u.SetExcluded(node.FieldSettings) return u}
// ClearSettings clears the value of the "settings" field.func (u *NodeUpsert) ClearSettings() *NodeUpsert { u.SetNull(node.FieldSettings) return u}
// SetWeight sets the "weight" field.func (u *NodeUpsert) SetWeight(v int) *NodeUpsert { u.Set(node.FieldWeight, v) return u}
// UpdateWeight sets the "weight" field to the value that was provided on create.func (u *NodeUpsert) UpdateWeight() *NodeUpsert { u.SetExcluded(node.FieldWeight) return u}
// AddWeight adds v to the "weight" field.func (u *NodeUpsert) AddWeight(v int) *NodeUpsert { u.Add(node.FieldWeight, 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.Node.Create().// OnConflict(// sql.ResolveWithNewValues(),// ).// Exec(ctx)func (u *NodeUpsertOne) UpdateNewValues() *NodeUpsertOne { 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(node.FieldCreatedAt) } })) return u}
// Ignore sets each column to itself in case of conflict.// Using this option is equivalent to using://// client.Node.Create().// OnConflict(sql.ResolveWithIgnore()).// Exec(ctx)func (u *NodeUpsertOne) Ignore() *NodeUpsertOne { 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 *NodeUpsertOne) DoNothing() *NodeUpsertOne { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u}
// Update allows overriding fields `UPDATE` values. See the NodeCreate.OnConflict// documentation for more info.func (u *NodeUpsertOne) Update(set func(*NodeUpsert)) *NodeUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&NodeUpsert{UpdateSet: update}) })) return u}
// SetUpdatedAt sets the "updated_at" field.func (u *NodeUpsertOne) SetUpdatedAt(v time.Time) *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.SetUpdatedAt(v) })}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.func (u *NodeUpsertOne) UpdateUpdatedAt() *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.UpdateUpdatedAt() })}
// SetDeletedAt sets the "deleted_at" field.func (u *NodeUpsertOne) SetDeletedAt(v time.Time) *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.SetDeletedAt(v) })}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.func (u *NodeUpsertOne) UpdateDeletedAt() *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.UpdateDeletedAt() })}
// ClearDeletedAt clears the value of the "deleted_at" field.func (u *NodeUpsertOne) ClearDeletedAt() *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.ClearDeletedAt() })}
// SetStatus sets the "status" field.func (u *NodeUpsertOne) SetStatus(v node.Status) *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.SetStatus(v) })}
// UpdateStatus sets the "status" field to the value that was provided on create.func (u *NodeUpsertOne) UpdateStatus() *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.UpdateStatus() })}
// SetName sets the "name" field.func (u *NodeUpsertOne) SetName(v string) *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.SetName(v) })}
// UpdateName sets the "name" field to the value that was provided on create.func (u *NodeUpsertOne) UpdateName() *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.UpdateName() })}
// SetType sets the "type" field.func (u *NodeUpsertOne) SetType(v node.Type) *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.SetType(v) })}
// UpdateType sets the "type" field to the value that was provided on create.func (u *NodeUpsertOne) UpdateType() *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.UpdateType() })}
// SetServer sets the "server" field.func (u *NodeUpsertOne) SetServer(v string) *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.SetServer(v) })}
// UpdateServer sets the "server" field to the value that was provided on create.func (u *NodeUpsertOne) UpdateServer() *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.UpdateServer() })}
// ClearServer clears the value of the "server" field.func (u *NodeUpsertOne) ClearServer() *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.ClearServer() })}
// SetSlaveKey sets the "slave_key" field.func (u *NodeUpsertOne) SetSlaveKey(v string) *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.SetSlaveKey(v) })}
// UpdateSlaveKey sets the "slave_key" field to the value that was provided on create.func (u *NodeUpsertOne) UpdateSlaveKey() *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.UpdateSlaveKey() })}
// ClearSlaveKey clears the value of the "slave_key" field.func (u *NodeUpsertOne) ClearSlaveKey() *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.ClearSlaveKey() })}
// SetCapabilities sets the "capabilities" field.func (u *NodeUpsertOne) SetCapabilities(v *boolset.BooleanSet) *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.SetCapabilities(v) })}
// UpdateCapabilities sets the "capabilities" field to the value that was provided on create.func (u *NodeUpsertOne) UpdateCapabilities() *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.UpdateCapabilities() })}
// SetSettings sets the "settings" field.func (u *NodeUpsertOne) SetSettings(v *types.NodeSetting) *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.SetSettings(v) })}
// UpdateSettings sets the "settings" field to the value that was provided on create.func (u *NodeUpsertOne) UpdateSettings() *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.UpdateSettings() })}
// ClearSettings clears the value of the "settings" field.func (u *NodeUpsertOne) ClearSettings() *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.ClearSettings() })}
// SetWeight sets the "weight" field.func (u *NodeUpsertOne) SetWeight(v int) *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.SetWeight(v) })}
// AddWeight adds v to the "weight" field.func (u *NodeUpsertOne) AddWeight(v int) *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.AddWeight(v) })}
// UpdateWeight sets the "weight" field to the value that was provided on create.func (u *NodeUpsertOne) UpdateWeight() *NodeUpsertOne { return u.Update(func(s *NodeUpsert) { s.UpdateWeight() })}
// Exec executes the query.func (u *NodeUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { return errors.New("ent: missing options for NodeCreate.OnConflict") } return u.create.Exec(ctx)}
// ExecX is like Exec, but panics if an error occurs.func (u *NodeUpsertOne) 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 *NodeUpsertOne) ID(ctx context.Context) (id int, 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 *NodeUpsertOne) IDX(ctx context.Context) int { id, err := u.ID(ctx) if err != nil { panic(err) } return id}
func (m *NodeCreate) SetRawID(t int) *NodeCreate { m.mutation.SetRawID(t) return m}
// NodeCreateBulk is the builder for creating many Node entities in bulk.type NodeCreateBulk struct { config err error builders []*NodeCreate conflict []sql.ConflictOption}
// Save creates the Node entities in the database.func (ncb *NodeCreateBulk) Save(ctx context.Context) ([]*Node, error) { if ncb.err != nil { return nil, ncb.err } specs := make([]*sqlgraph.CreateSpec, len(ncb.builders)) nodes := make([]*Node, len(ncb.builders)) mutators := make([]Mutator, len(ncb.builders)) for i := range ncb.builders { func(i int, root context.Context) { builder := ncb.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*NodeMutation) 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, ncb.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} spec.OnConflict = ncb.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ncb.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 = int(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, ncb.builders[0].mutation); err != nil { return nil, err } } return nodes, nil}
// SaveX is like Save, but panics if an error occurs.func (ncb *NodeCreateBulk) SaveX(ctx context.Context) []*Node { v, err := ncb.Save(ctx) if err != nil { panic(err) } return v}
// Exec executes the query.func (ncb *NodeCreateBulk) Exec(ctx context.Context) error { _, err := ncb.Save(ctx) return err}
// ExecX is like Exec, but panics if an error occurs.func (ncb *NodeCreateBulk) ExecX(ctx context.Context) { if err := ncb.Exec(ctx); err != nil { panic(err) }}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause// of the `INSERT` statement. For example://// client.Node.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.NodeUpsert) {// SetCreatedAt(v+v).// }).// Exec(ctx)func (ncb *NodeCreateBulk) OnConflict(opts ...sql.ConflictOption) *NodeUpsertBulk { ncb.conflict = opts return &NodeUpsertBulk{ create: ncb, }}
// OnConflictColumns calls `OnConflict` and configures the columns// as conflict target. Using this option is equivalent to using://// client.Node.Create().// OnConflict(sql.ConflictColumns(columns...)).// Exec(ctx)func (ncb *NodeCreateBulk) OnConflictColumns(columns ...string) *NodeUpsertBulk { ncb.conflict = append(ncb.conflict, sql.ConflictColumns(columns...)) return &NodeUpsertBulk{ create: ncb, }}
// NodeUpsertBulk is the builder for "upsert"-ing// a bulk of Node nodes.type NodeUpsertBulk struct { create *NodeCreateBulk}
// UpdateNewValues updates the mutable fields using the new values that// were set on create. Using this option is equivalent to using://// client.Node.Create().// OnConflict(// sql.ResolveWithNewValues(),// ).// Exec(ctx)func (u *NodeUpsertBulk) UpdateNewValues() *NodeUpsertBulk { 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(node.FieldCreatedAt) } } })) return u}
// Ignore sets each column to itself in case of conflict.// Using this option is equivalent to using://// client.Node.Create().// OnConflict(sql.ResolveWithIgnore()).// Exec(ctx)func (u *NodeUpsertBulk) Ignore() *NodeUpsertBulk { 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 *NodeUpsertBulk) DoNothing() *NodeUpsertBulk { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u}
// Update allows overriding fields `UPDATE` values. See the NodeCreateBulk.OnConflict// documentation for more info.func (u *NodeUpsertBulk) Update(set func(*NodeUpsert)) *NodeUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&NodeUpsert{UpdateSet: update}) })) return u}
// SetUpdatedAt sets the "updated_at" field.func (u *NodeUpsertBulk) SetUpdatedAt(v time.Time) *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.SetUpdatedAt(v) })}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.func (u *NodeUpsertBulk) UpdateUpdatedAt() *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.UpdateUpdatedAt() })}
// SetDeletedAt sets the "deleted_at" field.func (u *NodeUpsertBulk) SetDeletedAt(v time.Time) *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.SetDeletedAt(v) })}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.func (u *NodeUpsertBulk) UpdateDeletedAt() *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.UpdateDeletedAt() })}
// ClearDeletedAt clears the value of the "deleted_at" field.func (u *NodeUpsertBulk) ClearDeletedAt() *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.ClearDeletedAt() })}
// SetStatus sets the "status" field.func (u *NodeUpsertBulk) SetStatus(v node.Status) *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.SetStatus(v) })}
// UpdateStatus sets the "status" field to the value that was provided on create.func (u *NodeUpsertBulk) UpdateStatus() *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.UpdateStatus() })}
// SetName sets the "name" field.func (u *NodeUpsertBulk) SetName(v string) *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.SetName(v) })}
// UpdateName sets the "name" field to the value that was provided on create.func (u *NodeUpsertBulk) UpdateName() *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.UpdateName() })}
// SetType sets the "type" field.func (u *NodeUpsertBulk) SetType(v node.Type) *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.SetType(v) })}
// UpdateType sets the "type" field to the value that was provided on create.func (u *NodeUpsertBulk) UpdateType() *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.UpdateType() })}
// SetServer sets the "server" field.func (u *NodeUpsertBulk) SetServer(v string) *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.SetServer(v) })}
// UpdateServer sets the "server" field to the value that was provided on create.func (u *NodeUpsertBulk) UpdateServer() *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.UpdateServer() })}
// ClearServer clears the value of the "server" field.func (u *NodeUpsertBulk) ClearServer() *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.ClearServer() })}
// SetSlaveKey sets the "slave_key" field.func (u *NodeUpsertBulk) SetSlaveKey(v string) *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.SetSlaveKey(v) })}
// UpdateSlaveKey sets the "slave_key" field to the value that was provided on create.func (u *NodeUpsertBulk) UpdateSlaveKey() *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.UpdateSlaveKey() })}
// ClearSlaveKey clears the value of the "slave_key" field.func (u *NodeUpsertBulk) ClearSlaveKey() *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.ClearSlaveKey() })}
// SetCapabilities sets the "capabilities" field.func (u *NodeUpsertBulk) SetCapabilities(v *boolset.BooleanSet) *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.SetCapabilities(v) })}
// UpdateCapabilities sets the "capabilities" field to the value that was provided on create.func (u *NodeUpsertBulk) UpdateCapabilities() *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.UpdateCapabilities() })}
// SetSettings sets the "settings" field.func (u *NodeUpsertBulk) SetSettings(v *types.NodeSetting) *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.SetSettings(v) })}
// UpdateSettings sets the "settings" field to the value that was provided on create.func (u *NodeUpsertBulk) UpdateSettings() *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.UpdateSettings() })}
// ClearSettings clears the value of the "settings" field.func (u *NodeUpsertBulk) ClearSettings() *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.ClearSettings() })}
// SetWeight sets the "weight" field.func (u *NodeUpsertBulk) SetWeight(v int) *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.SetWeight(v) })}
// AddWeight adds v to the "weight" field.func (u *NodeUpsertBulk) AddWeight(v int) *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.AddWeight(v) })}
// UpdateWeight sets the "weight" field to the value that was provided on create.func (u *NodeUpsertBulk) UpdateWeight() *NodeUpsertBulk { return u.Update(func(s *NodeUpsert) { s.UpdateWeight() })}
// Exec executes the query.func (u *NodeUpsertBulk) 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 NodeCreateBulk instead", i) } } if len(u.create.conflict) == 0 { return errors.New("ent: missing options for NodeCreateBulk.OnConflict") } return u.create.Exec(ctx)}
// ExecX is like Exec, but panics if an error occurs.func (u *NodeUpsertBulk) ExecX(ctx context.Context) { if err := u.create.Exec(ctx); err != nil { panic(err) }}