代码拉取完成,页面将自动刷新
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"gitee.com/yuLingNet/simple-iot-basic-rpc/ent/company"
"gitee.com/yuLingNet/simple-iot-basic-rpc/ent/device"
"gitee.com/yuLingNet/simple-iot-basic-rpc/ent/deviceprop"
"gitee.com/yuLingNet/simple-iot-basic-rpc/ent/member"
"gitee.com/yuLingNet/simple-iot-basic-rpc/ent/product"
uuid "github.com/gofrs/uuid/v5"
)
// DeviceCreate is the builder for creating a Device entity.
type DeviceCreate struct {
config
mutation *DeviceMutation
hooks []Hook
conflict []sql.ConflictOption
}
// SetCreatedAt sets the "created_at" field.
func (dc *DeviceCreate) SetCreatedAt(t time.Time) *DeviceCreate {
dc.mutation.SetCreatedAt(t)
return dc
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableCreatedAt(t *time.Time) *DeviceCreate {
if t != nil {
dc.SetCreatedAt(*t)
}
return dc
}
// SetUpdatedAt sets the "updated_at" field.
func (dc *DeviceCreate) SetUpdatedAt(t time.Time) *DeviceCreate {
dc.mutation.SetUpdatedAt(t)
return dc
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableUpdatedAt(t *time.Time) *DeviceCreate {
if t != nil {
dc.SetUpdatedAt(*t)
}
return dc
}
// SetStatus sets the "status" field.
func (dc *DeviceCreate) SetStatus(u uint8) *DeviceCreate {
dc.mutation.SetStatus(u)
return dc
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableStatus(u *uint8) *DeviceCreate {
if u != nil {
dc.SetStatus(*u)
}
return dc
}
// SetSort sets the "sort" field.
func (dc *DeviceCreate) SetSort(u uint32) *DeviceCreate {
dc.mutation.SetSort(u)
return dc
}
// SetNillableSort sets the "sort" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableSort(u *uint32) *DeviceCreate {
if u != nil {
dc.SetSort(*u)
}
return dc
}
// SetProductKey sets the "productKey" field.
func (dc *DeviceCreate) SetProductKey(s string) *DeviceCreate {
dc.mutation.SetProductKey(s)
return dc
}
// SetIotID sets the "iotID" field.
func (dc *DeviceCreate) SetIotID(s string) *DeviceCreate {
dc.mutation.SetIotID(s)
return dc
}
// SetDeviceName sets the "deviceName" field.
func (dc *DeviceCreate) SetDeviceName(s string) *DeviceCreate {
dc.mutation.SetDeviceName(s)
return dc
}
// SetDeviceSecret sets the "deviceSecret" field.
func (dc *DeviceCreate) SetDeviceSecret(s string) *DeviceCreate {
dc.mutation.SetDeviceSecret(s)
return dc
}
// SetNillableDeviceSecret sets the "deviceSecret" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableDeviceSecret(s *string) *DeviceCreate {
if s != nil {
dc.SetDeviceSecret(*s)
}
return dc
}
// SetDeviceStatus sets the "deviceStatus" field.
func (dc *DeviceCreate) SetDeviceStatus(s string) *DeviceCreate {
dc.mutation.SetDeviceStatus(s)
return dc
}
// SetNillableDeviceStatus sets the "deviceStatus" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableDeviceStatus(s *string) *DeviceCreate {
if s != nil {
dc.SetDeviceStatus(*s)
}
return dc
}
// SetNickname sets the "nickname" field.
func (dc *DeviceCreate) SetNickname(s string) *DeviceCreate {
dc.mutation.SetNickname(s)
return dc
}
// SetNillableNickname sets the "nickname" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableNickname(s *string) *DeviceCreate {
if s != nil {
dc.SetNickname(*s)
}
return dc
}
// SetGmtCreate sets the "gmtCreate" field.
func (dc *DeviceCreate) SetGmtCreate(s string) *DeviceCreate {
dc.mutation.SetGmtCreate(s)
return dc
}
// SetNillableGmtCreate sets the "gmtCreate" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableGmtCreate(s *string) *DeviceCreate {
if s != nil {
dc.SetGmtCreate(*s)
}
return dc
}
// SetGmtModified sets the "gmtModified" field.
func (dc *DeviceCreate) SetGmtModified(s string) *DeviceCreate {
dc.mutation.SetGmtModified(s)
return dc
}
// SetNillableGmtModified sets the "gmtModified" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableGmtModified(s *string) *DeviceCreate {
if s != nil {
dc.SetGmtModified(*s)
}
return dc
}
// SetUtcCreate sets the "utcCreate" field.
func (dc *DeviceCreate) SetUtcCreate(s string) *DeviceCreate {
dc.mutation.SetUtcCreate(s)
return dc
}
// SetNillableUtcCreate sets the "utcCreate" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableUtcCreate(s *string) *DeviceCreate {
if s != nil {
dc.SetUtcCreate(*s)
}
return dc
}
// SetUtcModified sets the "utcModified" field.
func (dc *DeviceCreate) SetUtcModified(s string) *DeviceCreate {
dc.mutation.SetUtcModified(s)
return dc
}
// SetNillableUtcModified sets the "utcModified" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableUtcModified(s *string) *DeviceCreate {
if s != nil {
dc.SetUtcModified(*s)
}
return dc
}
// SetOperationalStatusCode sets the "operationalStatusCode" field.
func (dc *DeviceCreate) SetOperationalStatusCode(s string) *DeviceCreate {
dc.mutation.SetOperationalStatusCode(s)
return dc
}
// SetNillableOperationalStatusCode sets the "operationalStatusCode" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableOperationalStatusCode(s *string) *DeviceCreate {
if s != nil {
dc.SetOperationalStatusCode(*s)
}
return dc
}
// SetOperationalStatus sets the "operationalStatus" field.
func (dc *DeviceCreate) SetOperationalStatus(s string) *DeviceCreate {
dc.mutation.SetOperationalStatus(s)
return dc
}
// SetNillableOperationalStatus sets the "operationalStatus" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableOperationalStatus(s *string) *DeviceCreate {
if s != nil {
dc.SetOperationalStatus(*s)
}
return dc
}
// SetTag sets the "tag" field.
func (dc *DeviceCreate) SetTag(u uint64) *DeviceCreate {
dc.mutation.SetTag(u)
return dc
}
// SetNillableTag sets the "tag" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableTag(u *uint64) *DeviceCreate {
if u != nil {
dc.SetTag(*u)
}
return dc
}
// SetFirmwareVersion sets the "firmwareVersion" field.
func (dc *DeviceCreate) SetFirmwareVersion(s string) *DeviceCreate {
dc.mutation.SetFirmwareVersion(s)
return dc
}
// SetNillableFirmwareVersion sets the "firmwareVersion" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableFirmwareVersion(s *string) *DeviceCreate {
if s != nil {
dc.SetFirmwareVersion(*s)
}
return dc
}
// SetGmtActive sets the "gmtActive" field.
func (dc *DeviceCreate) SetGmtActive(s string) *DeviceCreate {
dc.mutation.SetGmtActive(s)
return dc
}
// SetNillableGmtActive sets the "gmtActive" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableGmtActive(s *string) *DeviceCreate {
if s != nil {
dc.SetGmtActive(*s)
}
return dc
}
// SetGmtOnline sets the "gmtOnline" field.
func (dc *DeviceCreate) SetGmtOnline(s string) *DeviceCreate {
dc.mutation.SetGmtOnline(s)
return dc
}
// SetNillableGmtOnline sets the "gmtOnline" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableGmtOnline(s *string) *DeviceCreate {
if s != nil {
dc.SetGmtOnline(*s)
}
return dc
}
// SetIPAddress sets the "IPAddress" field.
func (dc *DeviceCreate) SetIPAddress(s string) *DeviceCreate {
dc.mutation.SetIPAddress(s)
return dc
}
// SetNillableIPAddress sets the "IPAddress" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableIPAddress(s *string) *DeviceCreate {
if s != nil {
dc.SetIPAddress(*s)
}
return dc
}
// SetNodeType sets the "nodeType" field.
func (dc *DeviceCreate) SetNodeType(i int32) *DeviceCreate {
dc.mutation.SetNodeType(i)
return dc
}
// SetNillableNodeType sets the "nodeType" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableNodeType(i *int32) *DeviceCreate {
if i != nil {
dc.SetNodeType(*i)
}
return dc
}
// SetOwner sets the "owner" field.
func (dc *DeviceCreate) SetOwner(b bool) *DeviceCreate {
dc.mutation.SetOwner(b)
return dc
}
// SetNillableOwner sets the "owner" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableOwner(b *bool) *DeviceCreate {
if b != nil {
dc.SetOwner(*b)
}
return dc
}
// SetProductName sets the "productName" field.
func (dc *DeviceCreate) SetProductName(s string) *DeviceCreate {
dc.mutation.SetProductName(s)
return dc
}
// SetNillableProductName sets the "productName" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableProductName(s *string) *DeviceCreate {
if s != nil {
dc.SetProductName(*s)
}
return dc
}
// SetRegion sets the "region" field.
func (dc *DeviceCreate) SetRegion(s string) *DeviceCreate {
dc.mutation.SetRegion(s)
return dc
}
// SetNillableRegion sets the "region" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableRegion(s *string) *DeviceCreate {
if s != nil {
dc.SetRegion(*s)
}
return dc
}
// SetUtcActive sets the "utcActive" field.
func (dc *DeviceCreate) SetUtcActive(s string) *DeviceCreate {
dc.mutation.SetUtcActive(s)
return dc
}
// SetNillableUtcActive sets the "utcActive" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableUtcActive(s *string) *DeviceCreate {
if s != nil {
dc.SetUtcActive(*s)
}
return dc
}
// SetUtcOnline sets the "utcOnline" field.
func (dc *DeviceCreate) SetUtcOnline(s string) *DeviceCreate {
dc.mutation.SetUtcOnline(s)
return dc
}
// SetNillableUtcOnline sets the "utcOnline" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableUtcOnline(s *string) *DeviceCreate {
if s != nil {
dc.SetUtcOnline(*s)
}
return dc
}
// SetID sets the "id" field.
func (dc *DeviceCreate) SetID(u uuid.UUID) *DeviceCreate {
dc.mutation.SetID(u)
return dc
}
// SetNillableID sets the "id" field if the given value is not nil.
func (dc *DeviceCreate) SetNillableID(u *uuid.UUID) *DeviceCreate {
if u != nil {
dc.SetID(*u)
}
return dc
}
// SetProductID sets the "product" edge to the Product entity by ID.
func (dc *DeviceCreate) SetProductID(id uuid.UUID) *DeviceCreate {
dc.mutation.SetProductID(id)
return dc
}
// SetNillableProductID sets the "product" edge to the Product entity by ID if the given value is not nil.
func (dc *DeviceCreate) SetNillableProductID(id *uuid.UUID) *DeviceCreate {
if id != nil {
dc = dc.SetProductID(*id)
}
return dc
}
// SetProduct sets the "product" edge to the Product entity.
func (dc *DeviceCreate) SetProduct(p *Product) *DeviceCreate {
return dc.SetProductID(p.ID)
}
// SetPropID sets the "prop" edge to the DeviceProp entity by ID.
func (dc *DeviceCreate) SetPropID(id uint64) *DeviceCreate {
dc.mutation.SetPropID(id)
return dc
}
// SetNillablePropID sets the "prop" edge to the DeviceProp entity by ID if the given value is not nil.
func (dc *DeviceCreate) SetNillablePropID(id *uint64) *DeviceCreate {
if id != nil {
dc = dc.SetPropID(*id)
}
return dc
}
// SetProp sets the "prop" edge to the DeviceProp entity.
func (dc *DeviceCreate) SetProp(d *DeviceProp) *DeviceCreate {
return dc.SetPropID(d.ID)
}
// AddCompanyIDs adds the "companies" edge to the Company entity by IDs.
func (dc *DeviceCreate) AddCompanyIDs(ids ...uint64) *DeviceCreate {
dc.mutation.AddCompanyIDs(ids...)
return dc
}
// AddCompanies adds the "companies" edges to the Company entity.
func (dc *DeviceCreate) AddCompanies(c ...*Company) *DeviceCreate {
ids := make([]uint64, len(c))
for i := range c {
ids[i] = c[i].ID
}
return dc.AddCompanyIDs(ids...)
}
// AddMemberIDs adds the "members" edge to the Member entity by IDs.
func (dc *DeviceCreate) AddMemberIDs(ids ...uuid.UUID) *DeviceCreate {
dc.mutation.AddMemberIDs(ids...)
return dc
}
// AddMembers adds the "members" edges to the Member entity.
func (dc *DeviceCreate) AddMembers(m ...*Member) *DeviceCreate {
ids := make([]uuid.UUID, len(m))
for i := range m {
ids[i] = m[i].ID
}
return dc.AddMemberIDs(ids...)
}
// Mutation returns the DeviceMutation object of the builder.
func (dc *DeviceCreate) Mutation() *DeviceMutation {
return dc.mutation
}
// Save creates the Device in the database.
func (dc *DeviceCreate) Save(ctx context.Context) (*Device, error) {
dc.defaults()
return withHooks(ctx, dc.sqlSave, dc.mutation, dc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (dc *DeviceCreate) SaveX(ctx context.Context) *Device {
v, err := dc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (dc *DeviceCreate) Exec(ctx context.Context) error {
_, err := dc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (dc *DeviceCreate) ExecX(ctx context.Context) {
if err := dc.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (dc *DeviceCreate) defaults() {
if _, ok := dc.mutation.CreatedAt(); !ok {
v := device.DefaultCreatedAt()
dc.mutation.SetCreatedAt(v)
}
if _, ok := dc.mutation.UpdatedAt(); !ok {
v := device.DefaultUpdatedAt()
dc.mutation.SetUpdatedAt(v)
}
if _, ok := dc.mutation.Status(); !ok {
v := device.DefaultStatus
dc.mutation.SetStatus(v)
}
if _, ok := dc.mutation.Sort(); !ok {
v := device.DefaultSort
dc.mutation.SetSort(v)
}
if _, ok := dc.mutation.OperationalStatus(); !ok {
v := device.DefaultOperationalStatus
dc.mutation.SetOperationalStatus(v)
}
if _, ok := dc.mutation.NodeType(); !ok {
v := device.DefaultNodeType
dc.mutation.SetNodeType(v)
}
if _, ok := dc.mutation.Owner(); !ok {
v := device.DefaultOwner
dc.mutation.SetOwner(v)
}
if _, ok := dc.mutation.ID(); !ok {
v := device.DefaultID()
dc.mutation.SetID(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (dc *DeviceCreate) check() error {
if _, ok := dc.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Device.created_at"`)}
}
if _, ok := dc.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Device.updated_at"`)}
}
if _, ok := dc.mutation.Sort(); !ok {
return &ValidationError{Name: "sort", err: errors.New(`ent: missing required field "Device.sort"`)}
}
if _, ok := dc.mutation.ProductKey(); !ok {
return &ValidationError{Name: "productKey", err: errors.New(`ent: missing required field "Device.productKey"`)}
}
if _, ok := dc.mutation.IotID(); !ok {
return &ValidationError{Name: "iotID", err: errors.New(`ent: missing required field "Device.iotID"`)}
}
if _, ok := dc.mutation.DeviceName(); !ok {
return &ValidationError{Name: "deviceName", err: errors.New(`ent: missing required field "Device.deviceName"`)}
}
if _, ok := dc.mutation.NodeType(); !ok {
return &ValidationError{Name: "nodeType", err: errors.New(`ent: missing required field "Device.nodeType"`)}
}
return nil
}
func (dc *DeviceCreate) sqlSave(ctx context.Context) (*Device, error) {
if err := dc.check(); err != nil {
return nil, err
}
_node, _spec := dc.createSpec()
if err := sqlgraph.CreateNode(ctx, dc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
if _spec.ID.Value != nil {
if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
_node.ID = *id
} else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
return nil, err
}
}
dc.mutation.id = &_node.ID
dc.mutation.done = true
return _node, nil
}
func (dc *DeviceCreate) createSpec() (*Device, *sqlgraph.CreateSpec) {
var (
_node = &Device{config: dc.config}
_spec = sqlgraph.NewCreateSpec(device.Table, sqlgraph.NewFieldSpec(device.FieldID, field.TypeUUID))
)
_spec.OnConflict = dc.conflict
if id, ok := dc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = &id
}
if value, ok := dc.mutation.CreatedAt(); ok {
_spec.SetField(device.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := dc.mutation.UpdatedAt(); ok {
_spec.SetField(device.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := dc.mutation.Status(); ok {
_spec.SetField(device.FieldStatus, field.TypeUint8, value)
_node.Status = value
}
if value, ok := dc.mutation.Sort(); ok {
_spec.SetField(device.FieldSort, field.TypeUint32, value)
_node.Sort = value
}
if value, ok := dc.mutation.ProductKey(); ok {
_spec.SetField(device.FieldProductKey, field.TypeString, value)
_node.ProductKey = value
}
if value, ok := dc.mutation.IotID(); ok {
_spec.SetField(device.FieldIotID, field.TypeString, value)
_node.IotID = value
}
if value, ok := dc.mutation.DeviceName(); ok {
_spec.SetField(device.FieldDeviceName, field.TypeString, value)
_node.DeviceName = value
}
if value, ok := dc.mutation.DeviceSecret(); ok {
_spec.SetField(device.FieldDeviceSecret, field.TypeString, value)
_node.DeviceSecret = value
}
if value, ok := dc.mutation.DeviceStatus(); ok {
_spec.SetField(device.FieldDeviceStatus, field.TypeString, value)
_node.DeviceStatus = value
}
if value, ok := dc.mutation.Nickname(); ok {
_spec.SetField(device.FieldNickname, field.TypeString, value)
_node.Nickname = value
}
if value, ok := dc.mutation.GmtCreate(); ok {
_spec.SetField(device.FieldGmtCreate, field.TypeString, value)
_node.GmtCreate = value
}
if value, ok := dc.mutation.GmtModified(); ok {
_spec.SetField(device.FieldGmtModified, field.TypeString, value)
_node.GmtModified = value
}
if value, ok := dc.mutation.UtcCreate(); ok {
_spec.SetField(device.FieldUtcCreate, field.TypeString, value)
_node.UtcCreate = value
}
if value, ok := dc.mutation.UtcModified(); ok {
_spec.SetField(device.FieldUtcModified, field.TypeString, value)
_node.UtcModified = value
}
if value, ok := dc.mutation.OperationalStatusCode(); ok {
_spec.SetField(device.FieldOperationalStatusCode, field.TypeString, value)
_node.OperationalStatusCode = value
}
if value, ok := dc.mutation.OperationalStatus(); ok {
_spec.SetField(device.FieldOperationalStatus, field.TypeString, value)
_node.OperationalStatus = value
}
if value, ok := dc.mutation.Tag(); ok {
_spec.SetField(device.FieldTag, field.TypeUint64, value)
_node.Tag = value
}
if value, ok := dc.mutation.FirmwareVersion(); ok {
_spec.SetField(device.FieldFirmwareVersion, field.TypeString, value)
_node.FirmwareVersion = value
}
if value, ok := dc.mutation.GmtActive(); ok {
_spec.SetField(device.FieldGmtActive, field.TypeString, value)
_node.GmtActive = value
}
if value, ok := dc.mutation.GmtOnline(); ok {
_spec.SetField(device.FieldGmtOnline, field.TypeString, value)
_node.GmtOnline = value
}
if value, ok := dc.mutation.IPAddress(); ok {
_spec.SetField(device.FieldIPAddress, field.TypeString, value)
_node.IPAddress = value
}
if value, ok := dc.mutation.NodeType(); ok {
_spec.SetField(device.FieldNodeType, field.TypeInt32, value)
_node.NodeType = value
}
if value, ok := dc.mutation.Owner(); ok {
_spec.SetField(device.FieldOwner, field.TypeBool, value)
_node.Owner = value
}
if value, ok := dc.mutation.ProductName(); ok {
_spec.SetField(device.FieldProductName, field.TypeString, value)
_node.ProductName = value
}
if value, ok := dc.mutation.Region(); ok {
_spec.SetField(device.FieldRegion, field.TypeString, value)
_node.Region = value
}
if value, ok := dc.mutation.UtcActive(); ok {
_spec.SetField(device.FieldUtcActive, field.TypeString, value)
_node.UtcActive = value
}
if value, ok := dc.mutation.UtcOnline(); ok {
_spec.SetField(device.FieldUtcOnline, field.TypeString, value)
_node.UtcOnline = value
}
if nodes := dc.mutation.ProductIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: device.ProductTable,
Columns: []string{device.ProductColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(product.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.product_devices = &nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := dc.mutation.PropIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2O,
Inverse: false,
Table: device.PropTable,
Columns: []string{device.PropColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(deviceprop.FieldID, field.TypeUint64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := dc.mutation.CompaniesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: true,
Table: device.CompaniesTable,
Columns: device.CompaniesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(company.FieldID, field.TypeUint64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := dc.mutation.MembersIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: true,
Table: device.MembersTable,
Columns: device.MembersPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(member.FieldID, field.TypeUUID),
},
}
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.Device.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.DeviceUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func (dc *DeviceCreate) OnConflict(opts ...sql.ConflictOption) *DeviceUpsertOne {
dc.conflict = opts
return &DeviceUpsertOne{
create: dc,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.Device.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (dc *DeviceCreate) OnConflictColumns(columns ...string) *DeviceUpsertOne {
dc.conflict = append(dc.conflict, sql.ConflictColumns(columns...))
return &DeviceUpsertOne{
create: dc,
}
}
type (
// DeviceUpsertOne is the builder for "upsert"-ing
// one Device node.
DeviceUpsertOne struct {
create *DeviceCreate
}
// DeviceUpsert is the "OnConflict" setter.
DeviceUpsert struct {
*sql.UpdateSet
}
)
// SetUpdatedAt sets the "updated_at" field.
func (u *DeviceUpsert) SetUpdatedAt(v time.Time) *DeviceUpsert {
u.Set(device.FieldUpdatedAt, v)
return u
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateUpdatedAt() *DeviceUpsert {
u.SetExcluded(device.FieldUpdatedAt)
return u
}
// SetStatus sets the "status" field.
func (u *DeviceUpsert) SetStatus(v uint8) *DeviceUpsert {
u.Set(device.FieldStatus, v)
return u
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateStatus() *DeviceUpsert {
u.SetExcluded(device.FieldStatus)
return u
}
// AddStatus adds v to the "status" field.
func (u *DeviceUpsert) AddStatus(v uint8) *DeviceUpsert {
u.Add(device.FieldStatus, v)
return u
}
// ClearStatus clears the value of the "status" field.
func (u *DeviceUpsert) ClearStatus() *DeviceUpsert {
u.SetNull(device.FieldStatus)
return u
}
// SetSort sets the "sort" field.
func (u *DeviceUpsert) SetSort(v uint32) *DeviceUpsert {
u.Set(device.FieldSort, v)
return u
}
// UpdateSort sets the "sort" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateSort() *DeviceUpsert {
u.SetExcluded(device.FieldSort)
return u
}
// AddSort adds v to the "sort" field.
func (u *DeviceUpsert) AddSort(v uint32) *DeviceUpsert {
u.Add(device.FieldSort, v)
return u
}
// SetProductKey sets the "productKey" field.
func (u *DeviceUpsert) SetProductKey(v string) *DeviceUpsert {
u.Set(device.FieldProductKey, v)
return u
}
// UpdateProductKey sets the "productKey" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateProductKey() *DeviceUpsert {
u.SetExcluded(device.FieldProductKey)
return u
}
// SetIotID sets the "iotID" field.
func (u *DeviceUpsert) SetIotID(v string) *DeviceUpsert {
u.Set(device.FieldIotID, v)
return u
}
// UpdateIotID sets the "iotID" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateIotID() *DeviceUpsert {
u.SetExcluded(device.FieldIotID)
return u
}
// SetDeviceName sets the "deviceName" field.
func (u *DeviceUpsert) SetDeviceName(v string) *DeviceUpsert {
u.Set(device.FieldDeviceName, v)
return u
}
// UpdateDeviceName sets the "deviceName" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateDeviceName() *DeviceUpsert {
u.SetExcluded(device.FieldDeviceName)
return u
}
// SetDeviceSecret sets the "deviceSecret" field.
func (u *DeviceUpsert) SetDeviceSecret(v string) *DeviceUpsert {
u.Set(device.FieldDeviceSecret, v)
return u
}
// UpdateDeviceSecret sets the "deviceSecret" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateDeviceSecret() *DeviceUpsert {
u.SetExcluded(device.FieldDeviceSecret)
return u
}
// ClearDeviceSecret clears the value of the "deviceSecret" field.
func (u *DeviceUpsert) ClearDeviceSecret() *DeviceUpsert {
u.SetNull(device.FieldDeviceSecret)
return u
}
// SetDeviceStatus sets the "deviceStatus" field.
func (u *DeviceUpsert) SetDeviceStatus(v string) *DeviceUpsert {
u.Set(device.FieldDeviceStatus, v)
return u
}
// UpdateDeviceStatus sets the "deviceStatus" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateDeviceStatus() *DeviceUpsert {
u.SetExcluded(device.FieldDeviceStatus)
return u
}
// ClearDeviceStatus clears the value of the "deviceStatus" field.
func (u *DeviceUpsert) ClearDeviceStatus() *DeviceUpsert {
u.SetNull(device.FieldDeviceStatus)
return u
}
// SetNickname sets the "nickname" field.
func (u *DeviceUpsert) SetNickname(v string) *DeviceUpsert {
u.Set(device.FieldNickname, v)
return u
}
// UpdateNickname sets the "nickname" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateNickname() *DeviceUpsert {
u.SetExcluded(device.FieldNickname)
return u
}
// ClearNickname clears the value of the "nickname" field.
func (u *DeviceUpsert) ClearNickname() *DeviceUpsert {
u.SetNull(device.FieldNickname)
return u
}
// SetGmtCreate sets the "gmtCreate" field.
func (u *DeviceUpsert) SetGmtCreate(v string) *DeviceUpsert {
u.Set(device.FieldGmtCreate, v)
return u
}
// UpdateGmtCreate sets the "gmtCreate" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateGmtCreate() *DeviceUpsert {
u.SetExcluded(device.FieldGmtCreate)
return u
}
// ClearGmtCreate clears the value of the "gmtCreate" field.
func (u *DeviceUpsert) ClearGmtCreate() *DeviceUpsert {
u.SetNull(device.FieldGmtCreate)
return u
}
// SetGmtModified sets the "gmtModified" field.
func (u *DeviceUpsert) SetGmtModified(v string) *DeviceUpsert {
u.Set(device.FieldGmtModified, v)
return u
}
// UpdateGmtModified sets the "gmtModified" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateGmtModified() *DeviceUpsert {
u.SetExcluded(device.FieldGmtModified)
return u
}
// ClearGmtModified clears the value of the "gmtModified" field.
func (u *DeviceUpsert) ClearGmtModified() *DeviceUpsert {
u.SetNull(device.FieldGmtModified)
return u
}
// SetUtcCreate sets the "utcCreate" field.
func (u *DeviceUpsert) SetUtcCreate(v string) *DeviceUpsert {
u.Set(device.FieldUtcCreate, v)
return u
}
// UpdateUtcCreate sets the "utcCreate" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateUtcCreate() *DeviceUpsert {
u.SetExcluded(device.FieldUtcCreate)
return u
}
// ClearUtcCreate clears the value of the "utcCreate" field.
func (u *DeviceUpsert) ClearUtcCreate() *DeviceUpsert {
u.SetNull(device.FieldUtcCreate)
return u
}
// SetUtcModified sets the "utcModified" field.
func (u *DeviceUpsert) SetUtcModified(v string) *DeviceUpsert {
u.Set(device.FieldUtcModified, v)
return u
}
// UpdateUtcModified sets the "utcModified" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateUtcModified() *DeviceUpsert {
u.SetExcluded(device.FieldUtcModified)
return u
}
// ClearUtcModified clears the value of the "utcModified" field.
func (u *DeviceUpsert) ClearUtcModified() *DeviceUpsert {
u.SetNull(device.FieldUtcModified)
return u
}
// SetOperationalStatusCode sets the "operationalStatusCode" field.
func (u *DeviceUpsert) SetOperationalStatusCode(v string) *DeviceUpsert {
u.Set(device.FieldOperationalStatusCode, v)
return u
}
// UpdateOperationalStatusCode sets the "operationalStatusCode" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateOperationalStatusCode() *DeviceUpsert {
u.SetExcluded(device.FieldOperationalStatusCode)
return u
}
// ClearOperationalStatusCode clears the value of the "operationalStatusCode" field.
func (u *DeviceUpsert) ClearOperationalStatusCode() *DeviceUpsert {
u.SetNull(device.FieldOperationalStatusCode)
return u
}
// SetOperationalStatus sets the "operationalStatus" field.
func (u *DeviceUpsert) SetOperationalStatus(v string) *DeviceUpsert {
u.Set(device.FieldOperationalStatus, v)
return u
}
// UpdateOperationalStatus sets the "operationalStatus" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateOperationalStatus() *DeviceUpsert {
u.SetExcluded(device.FieldOperationalStatus)
return u
}
// ClearOperationalStatus clears the value of the "operationalStatus" field.
func (u *DeviceUpsert) ClearOperationalStatus() *DeviceUpsert {
u.SetNull(device.FieldOperationalStatus)
return u
}
// SetTag sets the "tag" field.
func (u *DeviceUpsert) SetTag(v uint64) *DeviceUpsert {
u.Set(device.FieldTag, v)
return u
}
// UpdateTag sets the "tag" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateTag() *DeviceUpsert {
u.SetExcluded(device.FieldTag)
return u
}
// AddTag adds v to the "tag" field.
func (u *DeviceUpsert) AddTag(v uint64) *DeviceUpsert {
u.Add(device.FieldTag, v)
return u
}
// ClearTag clears the value of the "tag" field.
func (u *DeviceUpsert) ClearTag() *DeviceUpsert {
u.SetNull(device.FieldTag)
return u
}
// SetFirmwareVersion sets the "firmwareVersion" field.
func (u *DeviceUpsert) SetFirmwareVersion(v string) *DeviceUpsert {
u.Set(device.FieldFirmwareVersion, v)
return u
}
// UpdateFirmwareVersion sets the "firmwareVersion" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateFirmwareVersion() *DeviceUpsert {
u.SetExcluded(device.FieldFirmwareVersion)
return u
}
// ClearFirmwareVersion clears the value of the "firmwareVersion" field.
func (u *DeviceUpsert) ClearFirmwareVersion() *DeviceUpsert {
u.SetNull(device.FieldFirmwareVersion)
return u
}
// SetGmtActive sets the "gmtActive" field.
func (u *DeviceUpsert) SetGmtActive(v string) *DeviceUpsert {
u.Set(device.FieldGmtActive, v)
return u
}
// UpdateGmtActive sets the "gmtActive" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateGmtActive() *DeviceUpsert {
u.SetExcluded(device.FieldGmtActive)
return u
}
// ClearGmtActive clears the value of the "gmtActive" field.
func (u *DeviceUpsert) ClearGmtActive() *DeviceUpsert {
u.SetNull(device.FieldGmtActive)
return u
}
// SetGmtOnline sets the "gmtOnline" field.
func (u *DeviceUpsert) SetGmtOnline(v string) *DeviceUpsert {
u.Set(device.FieldGmtOnline, v)
return u
}
// UpdateGmtOnline sets the "gmtOnline" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateGmtOnline() *DeviceUpsert {
u.SetExcluded(device.FieldGmtOnline)
return u
}
// ClearGmtOnline clears the value of the "gmtOnline" field.
func (u *DeviceUpsert) ClearGmtOnline() *DeviceUpsert {
u.SetNull(device.FieldGmtOnline)
return u
}
// SetIPAddress sets the "IPAddress" field.
func (u *DeviceUpsert) SetIPAddress(v string) *DeviceUpsert {
u.Set(device.FieldIPAddress, v)
return u
}
// UpdateIPAddress sets the "IPAddress" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateIPAddress() *DeviceUpsert {
u.SetExcluded(device.FieldIPAddress)
return u
}
// ClearIPAddress clears the value of the "IPAddress" field.
func (u *DeviceUpsert) ClearIPAddress() *DeviceUpsert {
u.SetNull(device.FieldIPAddress)
return u
}
// SetNodeType sets the "nodeType" field.
func (u *DeviceUpsert) SetNodeType(v int32) *DeviceUpsert {
u.Set(device.FieldNodeType, v)
return u
}
// UpdateNodeType sets the "nodeType" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateNodeType() *DeviceUpsert {
u.SetExcluded(device.FieldNodeType)
return u
}
// AddNodeType adds v to the "nodeType" field.
func (u *DeviceUpsert) AddNodeType(v int32) *DeviceUpsert {
u.Add(device.FieldNodeType, v)
return u
}
// SetOwner sets the "owner" field.
func (u *DeviceUpsert) SetOwner(v bool) *DeviceUpsert {
u.Set(device.FieldOwner, v)
return u
}
// UpdateOwner sets the "owner" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateOwner() *DeviceUpsert {
u.SetExcluded(device.FieldOwner)
return u
}
// ClearOwner clears the value of the "owner" field.
func (u *DeviceUpsert) ClearOwner() *DeviceUpsert {
u.SetNull(device.FieldOwner)
return u
}
// SetProductName sets the "productName" field.
func (u *DeviceUpsert) SetProductName(v string) *DeviceUpsert {
u.Set(device.FieldProductName, v)
return u
}
// UpdateProductName sets the "productName" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateProductName() *DeviceUpsert {
u.SetExcluded(device.FieldProductName)
return u
}
// ClearProductName clears the value of the "productName" field.
func (u *DeviceUpsert) ClearProductName() *DeviceUpsert {
u.SetNull(device.FieldProductName)
return u
}
// SetRegion sets the "region" field.
func (u *DeviceUpsert) SetRegion(v string) *DeviceUpsert {
u.Set(device.FieldRegion, v)
return u
}
// UpdateRegion sets the "region" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateRegion() *DeviceUpsert {
u.SetExcluded(device.FieldRegion)
return u
}
// ClearRegion clears the value of the "region" field.
func (u *DeviceUpsert) ClearRegion() *DeviceUpsert {
u.SetNull(device.FieldRegion)
return u
}
// SetUtcActive sets the "utcActive" field.
func (u *DeviceUpsert) SetUtcActive(v string) *DeviceUpsert {
u.Set(device.FieldUtcActive, v)
return u
}
// UpdateUtcActive sets the "utcActive" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateUtcActive() *DeviceUpsert {
u.SetExcluded(device.FieldUtcActive)
return u
}
// ClearUtcActive clears the value of the "utcActive" field.
func (u *DeviceUpsert) ClearUtcActive() *DeviceUpsert {
u.SetNull(device.FieldUtcActive)
return u
}
// SetUtcOnline sets the "utcOnline" field.
func (u *DeviceUpsert) SetUtcOnline(v string) *DeviceUpsert {
u.Set(device.FieldUtcOnline, v)
return u
}
// UpdateUtcOnline sets the "utcOnline" field to the value that was provided on create.
func (u *DeviceUpsert) UpdateUtcOnline() *DeviceUpsert {
u.SetExcluded(device.FieldUtcOnline)
return u
}
// ClearUtcOnline clears the value of the "utcOnline" field.
func (u *DeviceUpsert) ClearUtcOnline() *DeviceUpsert {
u.SetNull(device.FieldUtcOnline)
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.Device.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// sql.ResolveWith(func(u *sql.UpdateSet) {
// u.SetIgnore(device.FieldID)
// }),
// ).
// Exec(ctx)
func (u *DeviceUpsertOne) UpdateNewValues() *DeviceUpsertOne {
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(device.FieldID)
}
if _, exists := u.create.mutation.CreatedAt(); exists {
s.SetIgnore(device.FieldCreatedAt)
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.Device.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *DeviceUpsertOne) Ignore() *DeviceUpsertOne {
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 *DeviceUpsertOne) DoNothing() *DeviceUpsertOne {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the DeviceCreate.OnConflict
// documentation for more info.
func (u *DeviceUpsertOne) Update(set func(*DeviceUpsert)) *DeviceUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&DeviceUpsert{UpdateSet: update})
}))
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *DeviceUpsertOne) SetUpdatedAt(v time.Time) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateUpdatedAt() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateUpdatedAt()
})
}
// SetStatus sets the "status" field.
func (u *DeviceUpsertOne) SetStatus(v uint8) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetStatus(v)
})
}
// AddStatus adds v to the "status" field.
func (u *DeviceUpsertOne) AddStatus(v uint8) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.AddStatus(v)
})
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateStatus() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateStatus()
})
}
// ClearStatus clears the value of the "status" field.
func (u *DeviceUpsertOne) ClearStatus() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.ClearStatus()
})
}
// SetSort sets the "sort" field.
func (u *DeviceUpsertOne) SetSort(v uint32) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetSort(v)
})
}
// AddSort adds v to the "sort" field.
func (u *DeviceUpsertOne) AddSort(v uint32) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.AddSort(v)
})
}
// UpdateSort sets the "sort" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateSort() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateSort()
})
}
// SetProductKey sets the "productKey" field.
func (u *DeviceUpsertOne) SetProductKey(v string) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetProductKey(v)
})
}
// UpdateProductKey sets the "productKey" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateProductKey() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateProductKey()
})
}
// SetIotID sets the "iotID" field.
func (u *DeviceUpsertOne) SetIotID(v string) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetIotID(v)
})
}
// UpdateIotID sets the "iotID" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateIotID() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateIotID()
})
}
// SetDeviceName sets the "deviceName" field.
func (u *DeviceUpsertOne) SetDeviceName(v string) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetDeviceName(v)
})
}
// UpdateDeviceName sets the "deviceName" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateDeviceName() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateDeviceName()
})
}
// SetDeviceSecret sets the "deviceSecret" field.
func (u *DeviceUpsertOne) SetDeviceSecret(v string) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetDeviceSecret(v)
})
}
// UpdateDeviceSecret sets the "deviceSecret" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateDeviceSecret() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateDeviceSecret()
})
}
// ClearDeviceSecret clears the value of the "deviceSecret" field.
func (u *DeviceUpsertOne) ClearDeviceSecret() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.ClearDeviceSecret()
})
}
// SetDeviceStatus sets the "deviceStatus" field.
func (u *DeviceUpsertOne) SetDeviceStatus(v string) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetDeviceStatus(v)
})
}
// UpdateDeviceStatus sets the "deviceStatus" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateDeviceStatus() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateDeviceStatus()
})
}
// ClearDeviceStatus clears the value of the "deviceStatus" field.
func (u *DeviceUpsertOne) ClearDeviceStatus() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.ClearDeviceStatus()
})
}
// SetNickname sets the "nickname" field.
func (u *DeviceUpsertOne) SetNickname(v string) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetNickname(v)
})
}
// UpdateNickname sets the "nickname" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateNickname() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateNickname()
})
}
// ClearNickname clears the value of the "nickname" field.
func (u *DeviceUpsertOne) ClearNickname() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.ClearNickname()
})
}
// SetGmtCreate sets the "gmtCreate" field.
func (u *DeviceUpsertOne) SetGmtCreate(v string) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetGmtCreate(v)
})
}
// UpdateGmtCreate sets the "gmtCreate" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateGmtCreate() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateGmtCreate()
})
}
// ClearGmtCreate clears the value of the "gmtCreate" field.
func (u *DeviceUpsertOne) ClearGmtCreate() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.ClearGmtCreate()
})
}
// SetGmtModified sets the "gmtModified" field.
func (u *DeviceUpsertOne) SetGmtModified(v string) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetGmtModified(v)
})
}
// UpdateGmtModified sets the "gmtModified" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateGmtModified() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateGmtModified()
})
}
// ClearGmtModified clears the value of the "gmtModified" field.
func (u *DeviceUpsertOne) ClearGmtModified() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.ClearGmtModified()
})
}
// SetUtcCreate sets the "utcCreate" field.
func (u *DeviceUpsertOne) SetUtcCreate(v string) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetUtcCreate(v)
})
}
// UpdateUtcCreate sets the "utcCreate" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateUtcCreate() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateUtcCreate()
})
}
// ClearUtcCreate clears the value of the "utcCreate" field.
func (u *DeviceUpsertOne) ClearUtcCreate() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.ClearUtcCreate()
})
}
// SetUtcModified sets the "utcModified" field.
func (u *DeviceUpsertOne) SetUtcModified(v string) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetUtcModified(v)
})
}
// UpdateUtcModified sets the "utcModified" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateUtcModified() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateUtcModified()
})
}
// ClearUtcModified clears the value of the "utcModified" field.
func (u *DeviceUpsertOne) ClearUtcModified() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.ClearUtcModified()
})
}
// SetOperationalStatusCode sets the "operationalStatusCode" field.
func (u *DeviceUpsertOne) SetOperationalStatusCode(v string) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetOperationalStatusCode(v)
})
}
// UpdateOperationalStatusCode sets the "operationalStatusCode" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateOperationalStatusCode() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateOperationalStatusCode()
})
}
// ClearOperationalStatusCode clears the value of the "operationalStatusCode" field.
func (u *DeviceUpsertOne) ClearOperationalStatusCode() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.ClearOperationalStatusCode()
})
}
// SetOperationalStatus sets the "operationalStatus" field.
func (u *DeviceUpsertOne) SetOperationalStatus(v string) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetOperationalStatus(v)
})
}
// UpdateOperationalStatus sets the "operationalStatus" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateOperationalStatus() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateOperationalStatus()
})
}
// ClearOperationalStatus clears the value of the "operationalStatus" field.
func (u *DeviceUpsertOne) ClearOperationalStatus() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.ClearOperationalStatus()
})
}
// SetTag sets the "tag" field.
func (u *DeviceUpsertOne) SetTag(v uint64) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetTag(v)
})
}
// AddTag adds v to the "tag" field.
func (u *DeviceUpsertOne) AddTag(v uint64) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.AddTag(v)
})
}
// UpdateTag sets the "tag" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateTag() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateTag()
})
}
// ClearTag clears the value of the "tag" field.
func (u *DeviceUpsertOne) ClearTag() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.ClearTag()
})
}
// SetFirmwareVersion sets the "firmwareVersion" field.
func (u *DeviceUpsertOne) SetFirmwareVersion(v string) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetFirmwareVersion(v)
})
}
// UpdateFirmwareVersion sets the "firmwareVersion" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateFirmwareVersion() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateFirmwareVersion()
})
}
// ClearFirmwareVersion clears the value of the "firmwareVersion" field.
func (u *DeviceUpsertOne) ClearFirmwareVersion() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.ClearFirmwareVersion()
})
}
// SetGmtActive sets the "gmtActive" field.
func (u *DeviceUpsertOne) SetGmtActive(v string) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetGmtActive(v)
})
}
// UpdateGmtActive sets the "gmtActive" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateGmtActive() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateGmtActive()
})
}
// ClearGmtActive clears the value of the "gmtActive" field.
func (u *DeviceUpsertOne) ClearGmtActive() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.ClearGmtActive()
})
}
// SetGmtOnline sets the "gmtOnline" field.
func (u *DeviceUpsertOne) SetGmtOnline(v string) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetGmtOnline(v)
})
}
// UpdateGmtOnline sets the "gmtOnline" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateGmtOnline() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateGmtOnline()
})
}
// ClearGmtOnline clears the value of the "gmtOnline" field.
func (u *DeviceUpsertOne) ClearGmtOnline() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.ClearGmtOnline()
})
}
// SetIPAddress sets the "IPAddress" field.
func (u *DeviceUpsertOne) SetIPAddress(v string) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetIPAddress(v)
})
}
// UpdateIPAddress sets the "IPAddress" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateIPAddress() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateIPAddress()
})
}
// ClearIPAddress clears the value of the "IPAddress" field.
func (u *DeviceUpsertOne) ClearIPAddress() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.ClearIPAddress()
})
}
// SetNodeType sets the "nodeType" field.
func (u *DeviceUpsertOne) SetNodeType(v int32) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetNodeType(v)
})
}
// AddNodeType adds v to the "nodeType" field.
func (u *DeviceUpsertOne) AddNodeType(v int32) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.AddNodeType(v)
})
}
// UpdateNodeType sets the "nodeType" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateNodeType() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateNodeType()
})
}
// SetOwner sets the "owner" field.
func (u *DeviceUpsertOne) SetOwner(v bool) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetOwner(v)
})
}
// UpdateOwner sets the "owner" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateOwner() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateOwner()
})
}
// ClearOwner clears the value of the "owner" field.
func (u *DeviceUpsertOne) ClearOwner() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.ClearOwner()
})
}
// SetProductName sets the "productName" field.
func (u *DeviceUpsertOne) SetProductName(v string) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetProductName(v)
})
}
// UpdateProductName sets the "productName" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateProductName() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateProductName()
})
}
// ClearProductName clears the value of the "productName" field.
func (u *DeviceUpsertOne) ClearProductName() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.ClearProductName()
})
}
// SetRegion sets the "region" field.
func (u *DeviceUpsertOne) SetRegion(v string) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetRegion(v)
})
}
// UpdateRegion sets the "region" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateRegion() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateRegion()
})
}
// ClearRegion clears the value of the "region" field.
func (u *DeviceUpsertOne) ClearRegion() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.ClearRegion()
})
}
// SetUtcActive sets the "utcActive" field.
func (u *DeviceUpsertOne) SetUtcActive(v string) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetUtcActive(v)
})
}
// UpdateUtcActive sets the "utcActive" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateUtcActive() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateUtcActive()
})
}
// ClearUtcActive clears the value of the "utcActive" field.
func (u *DeviceUpsertOne) ClearUtcActive() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.ClearUtcActive()
})
}
// SetUtcOnline sets the "utcOnline" field.
func (u *DeviceUpsertOne) SetUtcOnline(v string) *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.SetUtcOnline(v)
})
}
// UpdateUtcOnline sets the "utcOnline" field to the value that was provided on create.
func (u *DeviceUpsertOne) UpdateUtcOnline() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.UpdateUtcOnline()
})
}
// ClearUtcOnline clears the value of the "utcOnline" field.
func (u *DeviceUpsertOne) ClearUtcOnline() *DeviceUpsertOne {
return u.Update(func(s *DeviceUpsert) {
s.ClearUtcOnline()
})
}
// Exec executes the query.
func (u *DeviceUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for DeviceCreate.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *DeviceUpsertOne) 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 *DeviceUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) {
if u.create.driver.Dialect() == dialect.MySQL {
// In case of "ON CONFLICT", there is no way to get back non-numeric ID
// fields from the database since MySQL does not support the RETURNING clause.
return id, errors.New("ent: DeviceUpsertOne.ID is not supported by MySQL driver. Use DeviceUpsertOne.Exec instead")
}
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 *DeviceUpsertOne) IDX(ctx context.Context) uuid.UUID {
id, err := u.ID(ctx)
if err != nil {
panic(err)
}
return id
}
// DeviceCreateBulk is the builder for creating many Device entities in bulk.
type DeviceCreateBulk struct {
config
err error
builders []*DeviceCreate
conflict []sql.ConflictOption
}
// Save creates the Device entities in the database.
func (dcb *DeviceCreateBulk) Save(ctx context.Context) ([]*Device, error) {
if dcb.err != nil {
return nil, dcb.err
}
specs := make([]*sqlgraph.CreateSpec, len(dcb.builders))
nodes := make([]*Device, len(dcb.builders))
mutators := make([]Mutator, len(dcb.builders))
for i := range dcb.builders {
func(i int, root context.Context) {
builder := dcb.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*DeviceMutation)
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, dcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
spec.OnConflict = dcb.conflict
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, dcb.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
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, dcb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (dcb *DeviceCreateBulk) SaveX(ctx context.Context) []*Device {
v, err := dcb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (dcb *DeviceCreateBulk) Exec(ctx context.Context) error {
_, err := dcb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (dcb *DeviceCreateBulk) ExecX(ctx context.Context) {
if err := dcb.Exec(ctx); err != nil {
panic(err)
}
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.Device.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.DeviceUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func (dcb *DeviceCreateBulk) OnConflict(opts ...sql.ConflictOption) *DeviceUpsertBulk {
dcb.conflict = opts
return &DeviceUpsertBulk{
create: dcb,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.Device.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (dcb *DeviceCreateBulk) OnConflictColumns(columns ...string) *DeviceUpsertBulk {
dcb.conflict = append(dcb.conflict, sql.ConflictColumns(columns...))
return &DeviceUpsertBulk{
create: dcb,
}
}
// DeviceUpsertBulk is the builder for "upsert"-ing
// a bulk of Device nodes.
type DeviceUpsertBulk struct {
create *DeviceCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.Device.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// sql.ResolveWith(func(u *sql.UpdateSet) {
// u.SetIgnore(device.FieldID)
// }),
// ).
// Exec(ctx)
func (u *DeviceUpsertBulk) UpdateNewValues() *DeviceUpsertBulk {
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(device.FieldID)
}
if _, exists := b.mutation.CreatedAt(); exists {
s.SetIgnore(device.FieldCreatedAt)
}
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.Device.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *DeviceUpsertBulk) Ignore() *DeviceUpsertBulk {
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 *DeviceUpsertBulk) DoNothing() *DeviceUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the DeviceCreateBulk.OnConflict
// documentation for more info.
func (u *DeviceUpsertBulk) Update(set func(*DeviceUpsert)) *DeviceUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&DeviceUpsert{UpdateSet: update})
}))
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *DeviceUpsertBulk) SetUpdatedAt(v time.Time) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateUpdatedAt() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateUpdatedAt()
})
}
// SetStatus sets the "status" field.
func (u *DeviceUpsertBulk) SetStatus(v uint8) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetStatus(v)
})
}
// AddStatus adds v to the "status" field.
func (u *DeviceUpsertBulk) AddStatus(v uint8) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.AddStatus(v)
})
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateStatus() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateStatus()
})
}
// ClearStatus clears the value of the "status" field.
func (u *DeviceUpsertBulk) ClearStatus() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.ClearStatus()
})
}
// SetSort sets the "sort" field.
func (u *DeviceUpsertBulk) SetSort(v uint32) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetSort(v)
})
}
// AddSort adds v to the "sort" field.
func (u *DeviceUpsertBulk) AddSort(v uint32) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.AddSort(v)
})
}
// UpdateSort sets the "sort" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateSort() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateSort()
})
}
// SetProductKey sets the "productKey" field.
func (u *DeviceUpsertBulk) SetProductKey(v string) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetProductKey(v)
})
}
// UpdateProductKey sets the "productKey" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateProductKey() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateProductKey()
})
}
// SetIotID sets the "iotID" field.
func (u *DeviceUpsertBulk) SetIotID(v string) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetIotID(v)
})
}
// UpdateIotID sets the "iotID" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateIotID() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateIotID()
})
}
// SetDeviceName sets the "deviceName" field.
func (u *DeviceUpsertBulk) SetDeviceName(v string) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetDeviceName(v)
})
}
// UpdateDeviceName sets the "deviceName" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateDeviceName() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateDeviceName()
})
}
// SetDeviceSecret sets the "deviceSecret" field.
func (u *DeviceUpsertBulk) SetDeviceSecret(v string) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetDeviceSecret(v)
})
}
// UpdateDeviceSecret sets the "deviceSecret" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateDeviceSecret() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateDeviceSecret()
})
}
// ClearDeviceSecret clears the value of the "deviceSecret" field.
func (u *DeviceUpsertBulk) ClearDeviceSecret() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.ClearDeviceSecret()
})
}
// SetDeviceStatus sets the "deviceStatus" field.
func (u *DeviceUpsertBulk) SetDeviceStatus(v string) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetDeviceStatus(v)
})
}
// UpdateDeviceStatus sets the "deviceStatus" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateDeviceStatus() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateDeviceStatus()
})
}
// ClearDeviceStatus clears the value of the "deviceStatus" field.
func (u *DeviceUpsertBulk) ClearDeviceStatus() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.ClearDeviceStatus()
})
}
// SetNickname sets the "nickname" field.
func (u *DeviceUpsertBulk) SetNickname(v string) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetNickname(v)
})
}
// UpdateNickname sets the "nickname" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateNickname() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateNickname()
})
}
// ClearNickname clears the value of the "nickname" field.
func (u *DeviceUpsertBulk) ClearNickname() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.ClearNickname()
})
}
// SetGmtCreate sets the "gmtCreate" field.
func (u *DeviceUpsertBulk) SetGmtCreate(v string) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetGmtCreate(v)
})
}
// UpdateGmtCreate sets the "gmtCreate" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateGmtCreate() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateGmtCreate()
})
}
// ClearGmtCreate clears the value of the "gmtCreate" field.
func (u *DeviceUpsertBulk) ClearGmtCreate() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.ClearGmtCreate()
})
}
// SetGmtModified sets the "gmtModified" field.
func (u *DeviceUpsertBulk) SetGmtModified(v string) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetGmtModified(v)
})
}
// UpdateGmtModified sets the "gmtModified" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateGmtModified() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateGmtModified()
})
}
// ClearGmtModified clears the value of the "gmtModified" field.
func (u *DeviceUpsertBulk) ClearGmtModified() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.ClearGmtModified()
})
}
// SetUtcCreate sets the "utcCreate" field.
func (u *DeviceUpsertBulk) SetUtcCreate(v string) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetUtcCreate(v)
})
}
// UpdateUtcCreate sets the "utcCreate" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateUtcCreate() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateUtcCreate()
})
}
// ClearUtcCreate clears the value of the "utcCreate" field.
func (u *DeviceUpsertBulk) ClearUtcCreate() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.ClearUtcCreate()
})
}
// SetUtcModified sets the "utcModified" field.
func (u *DeviceUpsertBulk) SetUtcModified(v string) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetUtcModified(v)
})
}
// UpdateUtcModified sets the "utcModified" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateUtcModified() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateUtcModified()
})
}
// ClearUtcModified clears the value of the "utcModified" field.
func (u *DeviceUpsertBulk) ClearUtcModified() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.ClearUtcModified()
})
}
// SetOperationalStatusCode sets the "operationalStatusCode" field.
func (u *DeviceUpsertBulk) SetOperationalStatusCode(v string) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetOperationalStatusCode(v)
})
}
// UpdateOperationalStatusCode sets the "operationalStatusCode" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateOperationalStatusCode() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateOperationalStatusCode()
})
}
// ClearOperationalStatusCode clears the value of the "operationalStatusCode" field.
func (u *DeviceUpsertBulk) ClearOperationalStatusCode() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.ClearOperationalStatusCode()
})
}
// SetOperationalStatus sets the "operationalStatus" field.
func (u *DeviceUpsertBulk) SetOperationalStatus(v string) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetOperationalStatus(v)
})
}
// UpdateOperationalStatus sets the "operationalStatus" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateOperationalStatus() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateOperationalStatus()
})
}
// ClearOperationalStatus clears the value of the "operationalStatus" field.
func (u *DeviceUpsertBulk) ClearOperationalStatus() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.ClearOperationalStatus()
})
}
// SetTag sets the "tag" field.
func (u *DeviceUpsertBulk) SetTag(v uint64) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetTag(v)
})
}
// AddTag adds v to the "tag" field.
func (u *DeviceUpsertBulk) AddTag(v uint64) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.AddTag(v)
})
}
// UpdateTag sets the "tag" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateTag() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateTag()
})
}
// ClearTag clears the value of the "tag" field.
func (u *DeviceUpsertBulk) ClearTag() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.ClearTag()
})
}
// SetFirmwareVersion sets the "firmwareVersion" field.
func (u *DeviceUpsertBulk) SetFirmwareVersion(v string) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetFirmwareVersion(v)
})
}
// UpdateFirmwareVersion sets the "firmwareVersion" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateFirmwareVersion() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateFirmwareVersion()
})
}
// ClearFirmwareVersion clears the value of the "firmwareVersion" field.
func (u *DeviceUpsertBulk) ClearFirmwareVersion() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.ClearFirmwareVersion()
})
}
// SetGmtActive sets the "gmtActive" field.
func (u *DeviceUpsertBulk) SetGmtActive(v string) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetGmtActive(v)
})
}
// UpdateGmtActive sets the "gmtActive" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateGmtActive() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateGmtActive()
})
}
// ClearGmtActive clears the value of the "gmtActive" field.
func (u *DeviceUpsertBulk) ClearGmtActive() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.ClearGmtActive()
})
}
// SetGmtOnline sets the "gmtOnline" field.
func (u *DeviceUpsertBulk) SetGmtOnline(v string) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetGmtOnline(v)
})
}
// UpdateGmtOnline sets the "gmtOnline" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateGmtOnline() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateGmtOnline()
})
}
// ClearGmtOnline clears the value of the "gmtOnline" field.
func (u *DeviceUpsertBulk) ClearGmtOnline() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.ClearGmtOnline()
})
}
// SetIPAddress sets the "IPAddress" field.
func (u *DeviceUpsertBulk) SetIPAddress(v string) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetIPAddress(v)
})
}
// UpdateIPAddress sets the "IPAddress" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateIPAddress() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateIPAddress()
})
}
// ClearIPAddress clears the value of the "IPAddress" field.
func (u *DeviceUpsertBulk) ClearIPAddress() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.ClearIPAddress()
})
}
// SetNodeType sets the "nodeType" field.
func (u *DeviceUpsertBulk) SetNodeType(v int32) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetNodeType(v)
})
}
// AddNodeType adds v to the "nodeType" field.
func (u *DeviceUpsertBulk) AddNodeType(v int32) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.AddNodeType(v)
})
}
// UpdateNodeType sets the "nodeType" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateNodeType() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateNodeType()
})
}
// SetOwner sets the "owner" field.
func (u *DeviceUpsertBulk) SetOwner(v bool) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetOwner(v)
})
}
// UpdateOwner sets the "owner" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateOwner() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateOwner()
})
}
// ClearOwner clears the value of the "owner" field.
func (u *DeviceUpsertBulk) ClearOwner() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.ClearOwner()
})
}
// SetProductName sets the "productName" field.
func (u *DeviceUpsertBulk) SetProductName(v string) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetProductName(v)
})
}
// UpdateProductName sets the "productName" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateProductName() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateProductName()
})
}
// ClearProductName clears the value of the "productName" field.
func (u *DeviceUpsertBulk) ClearProductName() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.ClearProductName()
})
}
// SetRegion sets the "region" field.
func (u *DeviceUpsertBulk) SetRegion(v string) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetRegion(v)
})
}
// UpdateRegion sets the "region" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateRegion() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateRegion()
})
}
// ClearRegion clears the value of the "region" field.
func (u *DeviceUpsertBulk) ClearRegion() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.ClearRegion()
})
}
// SetUtcActive sets the "utcActive" field.
func (u *DeviceUpsertBulk) SetUtcActive(v string) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetUtcActive(v)
})
}
// UpdateUtcActive sets the "utcActive" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateUtcActive() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateUtcActive()
})
}
// ClearUtcActive clears the value of the "utcActive" field.
func (u *DeviceUpsertBulk) ClearUtcActive() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.ClearUtcActive()
})
}
// SetUtcOnline sets the "utcOnline" field.
func (u *DeviceUpsertBulk) SetUtcOnline(v string) *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.SetUtcOnline(v)
})
}
// UpdateUtcOnline sets the "utcOnline" field to the value that was provided on create.
func (u *DeviceUpsertBulk) UpdateUtcOnline() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.UpdateUtcOnline()
})
}
// ClearUtcOnline clears the value of the "utcOnline" field.
func (u *DeviceUpsertBulk) ClearUtcOnline() *DeviceUpsertBulk {
return u.Update(func(s *DeviceUpsert) {
s.ClearUtcOnline()
})
}
// Exec executes the query.
func (u *DeviceUpsertBulk) 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 DeviceCreateBulk instead", i)
}
}
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for DeviceCreateBulk.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *DeviceUpsertBulk) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。