3 Star 0 Fork 0

广东宇凌网络科技有限公司 / simple-iot-data-rpc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
devicekpi_create.go 51.10 KB
一键复制 编辑 原始数据 按行查看 历史
HienGee 提交于 2024-04-26 11:27 . init
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869
// 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"
"gitee.com/yuLingNet/simple-iot-data-rpc/ent/devicekpi"
)
// DeviceKpiCreate is the builder for creating a DeviceKpi entity.
type DeviceKpiCreate struct {
config
mutation *DeviceKpiMutation
hooks []Hook
Table string
conflict []sql.ConflictOption
}
// SetCreatedAt sets the "created_at" field.
func (dkc *DeviceKpiCreate) SetCreatedAt(t time.Time) *DeviceKpiCreate {
dkc.mutation.SetCreatedAt(t)
return dkc
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (dkc *DeviceKpiCreate) SetNillableCreatedAt(t *time.Time) *DeviceKpiCreate {
if t != nil {
dkc.SetCreatedAt(*t)
}
return dkc
}
// SetUpdatedAt sets the "updated_at" field.
func (dkc *DeviceKpiCreate) SetUpdatedAt(t time.Time) *DeviceKpiCreate {
dkc.mutation.SetUpdatedAt(t)
return dkc
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (dkc *DeviceKpiCreate) SetNillableUpdatedAt(t *time.Time) *DeviceKpiCreate {
if t != nil {
dkc.SetUpdatedAt(*t)
}
return dkc
}
// SetStatus sets the "status" field.
func (dkc *DeviceKpiCreate) SetStatus(u uint8) *DeviceKpiCreate {
dkc.mutation.SetStatus(u)
return dkc
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (dkc *DeviceKpiCreate) SetNillableStatus(u *uint8) *DeviceKpiCreate {
if u != nil {
dkc.SetStatus(*u)
}
return dkc
}
// SetSort sets the "sort" field.
func (dkc *DeviceKpiCreate) SetSort(u uint32) *DeviceKpiCreate {
dkc.mutation.SetSort(u)
return dkc
}
// SetNillableSort sets the "sort" field if the given value is not nil.
func (dkc *DeviceKpiCreate) SetNillableSort(u *uint32) *DeviceKpiCreate {
if u != nil {
dkc.SetSort(*u)
}
return dkc
}
// SetIotID sets the "iotID" field.
func (dkc *DeviceKpiCreate) SetIotID(s string) *DeviceKpiCreate {
dkc.mutation.SetIotID(s)
return dkc
}
// SetDeviceName sets the "deviceName" field.
func (dkc *DeviceKpiCreate) SetDeviceName(s string) *DeviceKpiCreate {
dkc.mutation.SetDeviceName(s)
return dkc
}
// SetProductKey sets the "productKey" field.
func (dkc *DeviceKpiCreate) SetProductKey(s string) *DeviceKpiCreate {
dkc.mutation.SetProductKey(s)
return dkc
}
// SetKpi sets the "kpi" field.
func (dkc *DeviceKpiCreate) SetKpi(f float64) *DeviceKpiCreate {
dkc.mutation.SetKpi(f)
return dkc
}
// SetNillableKpi sets the "kpi" field if the given value is not nil.
func (dkc *DeviceKpiCreate) SetNillableKpi(f *float64) *DeviceKpiCreate {
if f != nil {
dkc.SetKpi(*f)
}
return dkc
}
// SetX sets the "x" field.
func (dkc *DeviceKpiCreate) SetX(f float64) *DeviceKpiCreate {
dkc.mutation.SetX(f)
return dkc
}
// SetNillableX sets the "x" field if the given value is not nil.
func (dkc *DeviceKpiCreate) SetNillableX(f *float64) *DeviceKpiCreate {
if f != nil {
dkc.SetX(*f)
}
return dkc
}
// SetY sets the "y" field.
func (dkc *DeviceKpiCreate) SetY(f float64) *DeviceKpiCreate {
dkc.mutation.SetY(f)
return dkc
}
// SetNillableY sets the "y" field if the given value is not nil.
func (dkc *DeviceKpiCreate) SetNillableY(f *float64) *DeviceKpiCreate {
if f != nil {
dkc.SetY(*f)
}
return dkc
}
// SetA sets the "a" field.
func (dkc *DeviceKpiCreate) SetA(f float64) *DeviceKpiCreate {
dkc.mutation.SetA(f)
return dkc
}
// SetNillableA sets the "a" field if the given value is not nil.
func (dkc *DeviceKpiCreate) SetNillableA(f *float64) *DeviceKpiCreate {
if f != nil {
dkc.SetA(*f)
}
return dkc
}
// SetB sets the "b" field.
func (dkc *DeviceKpiCreate) SetB(f float64) *DeviceKpiCreate {
dkc.mutation.SetB(f)
return dkc
}
// SetNillableB sets the "b" field if the given value is not nil.
func (dkc *DeviceKpiCreate) SetNillableB(f *float64) *DeviceKpiCreate {
if f != nil {
dkc.SetB(*f)
}
return dkc
}
// SetWeekKpi sets the "weekKpi" field.
func (dkc *DeviceKpiCreate) SetWeekKpi(f float64) *DeviceKpiCreate {
dkc.mutation.SetWeekKpi(f)
return dkc
}
// SetNillableWeekKpi sets the "weekKpi" field if the given value is not nil.
func (dkc *DeviceKpiCreate) SetNillableWeekKpi(f *float64) *DeviceKpiCreate {
if f != nil {
dkc.SetWeekKpi(*f)
}
return dkc
}
// SetMonthKpi sets the "monthKpi" field.
func (dkc *DeviceKpiCreate) SetMonthKpi(f float64) *DeviceKpiCreate {
dkc.mutation.SetMonthKpi(f)
return dkc
}
// SetNillableMonthKpi sets the "monthKpi" field if the given value is not nil.
func (dkc *DeviceKpiCreate) SetNillableMonthKpi(f *float64) *DeviceKpiCreate {
if f != nil {
dkc.SetMonthKpi(*f)
}
return dkc
}
// SetCurrentDay1 sets the "currentDay1" field.
func (dkc *DeviceKpiCreate) SetCurrentDay1(i int64) *DeviceKpiCreate {
dkc.mutation.SetCurrentDay1(i)
return dkc
}
// SetNillableCurrentDay1 sets the "currentDay1" field if the given value is not nil.
func (dkc *DeviceKpiCreate) SetNillableCurrentDay1(i *int64) *DeviceKpiCreate {
if i != nil {
dkc.SetCurrentDay1(*i)
}
return dkc
}
// SetCurrentDay7 sets the "currentDay7" field.
func (dkc *DeviceKpiCreate) SetCurrentDay7(i int64) *DeviceKpiCreate {
dkc.mutation.SetCurrentDay7(i)
return dkc
}
// SetNillableCurrentDay7 sets the "currentDay7" field if the given value is not nil.
func (dkc *DeviceKpiCreate) SetNillableCurrentDay7(i *int64) *DeviceKpiCreate {
if i != nil {
dkc.SetCurrentDay7(*i)
}
return dkc
}
// SetCurrentDay28 sets the "currentDay28" field.
func (dkc *DeviceKpiCreate) SetCurrentDay28(i int64) *DeviceKpiCreate {
dkc.mutation.SetCurrentDay28(i)
return dkc
}
// SetNillableCurrentDay28 sets the "currentDay28" field if the given value is not nil.
func (dkc *DeviceKpiCreate) SetNillableCurrentDay28(i *int64) *DeviceKpiCreate {
if i != nil {
dkc.SetCurrentDay28(*i)
}
return dkc
}
// SetID sets the "id" field.
func (dkc *DeviceKpiCreate) SetID(u uint64) *DeviceKpiCreate {
dkc.mutation.SetID(u)
return dkc
}
// Mutation returns the DeviceKpiMutation object of the builder.
func (dkc *DeviceKpiCreate) Mutation() *DeviceKpiMutation {
return dkc.mutation
}
// Save creates the DeviceKpi in the database.
func (dkc *DeviceKpiCreate) Save(ctx context.Context) (*DeviceKpi, error) {
dkc.defaults()
return withHooks(ctx, dkc.sqlSave, dkc.mutation, dkc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (dkc *DeviceKpiCreate) SaveX(ctx context.Context) *DeviceKpi {
v, err := dkc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (dkc *DeviceKpiCreate) Exec(ctx context.Context) error {
_, err := dkc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (dkc *DeviceKpiCreate) ExecX(ctx context.Context) {
if err := dkc.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (dkc *DeviceKpiCreate) defaults() {
if _, ok := dkc.mutation.CreatedAt(); !ok {
v := devicekpi.DefaultCreatedAt()
dkc.mutation.SetCreatedAt(v)
}
if _, ok := dkc.mutation.UpdatedAt(); !ok {
v := devicekpi.DefaultUpdatedAt()
dkc.mutation.SetUpdatedAt(v)
}
if _, ok := dkc.mutation.Status(); !ok {
v := devicekpi.DefaultStatus
dkc.mutation.SetStatus(v)
}
if _, ok := dkc.mutation.Sort(); !ok {
v := devicekpi.DefaultSort
dkc.mutation.SetSort(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (dkc *DeviceKpiCreate) check() error {
if _, ok := dkc.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "DeviceKpi.created_at"`)}
}
if _, ok := dkc.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "DeviceKpi.updated_at"`)}
}
if _, ok := dkc.mutation.Sort(); !ok {
return &ValidationError{Name: "sort", err: errors.New(`ent: missing required field "DeviceKpi.sort"`)}
}
if _, ok := dkc.mutation.IotID(); !ok {
return &ValidationError{Name: "iotID", err: errors.New(`ent: missing required field "DeviceKpi.iotID"`)}
}
if _, ok := dkc.mutation.DeviceName(); !ok {
return &ValidationError{Name: "deviceName", err: errors.New(`ent: missing required field "DeviceKpi.deviceName"`)}
}
if _, ok := dkc.mutation.ProductKey(); !ok {
return &ValidationError{Name: "productKey", err: errors.New(`ent: missing required field "DeviceKpi.productKey"`)}
}
return nil
}
func (dkc *DeviceKpiCreate) sqlSave(ctx context.Context) (*DeviceKpi, error) {
if err := dkc.check(); err != nil {
return nil, err
}
_node, _spec := dkc.createSpec()
if err := sqlgraph.CreateNode(ctx, dkc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
if _spec.ID.Value != _node.ID {
id := _spec.ID.Value.(int64)
_node.ID = uint64(id)
}
dkc.mutation.id = &_node.ID
dkc.mutation.done = true
return _node, nil
}
func (dkc *DeviceKpiCreate) createSpec() (*DeviceKpi, *sqlgraph.CreateSpec) {
var (
_node = &DeviceKpi{config: dkc.config}
_spec = sqlgraph.NewCreateSpec(devicekpi.Table, sqlgraph.NewFieldSpec(devicekpi.FieldID, field.TypeUint64))
)
if dkc.Table != "" {
_spec.Table = dkc.Table
}
_spec.OnConflict = dkc.conflict
if id, ok := dkc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := dkc.mutation.CreatedAt(); ok {
_spec.SetField(devicekpi.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := dkc.mutation.UpdatedAt(); ok {
_spec.SetField(devicekpi.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := dkc.mutation.Status(); ok {
_spec.SetField(devicekpi.FieldStatus, field.TypeUint8, value)
_node.Status = value
}
if value, ok := dkc.mutation.Sort(); ok {
_spec.SetField(devicekpi.FieldSort, field.TypeUint32, value)
_node.Sort = value
}
if value, ok := dkc.mutation.IotID(); ok {
_spec.SetField(devicekpi.FieldIotID, field.TypeString, value)
_node.IotID = value
}
if value, ok := dkc.mutation.DeviceName(); ok {
_spec.SetField(devicekpi.FieldDeviceName, field.TypeString, value)
_node.DeviceName = value
}
if value, ok := dkc.mutation.ProductKey(); ok {
_spec.SetField(devicekpi.FieldProductKey, field.TypeString, value)
_node.ProductKey = value
}
if value, ok := dkc.mutation.Kpi(); ok {
_spec.SetField(devicekpi.FieldKpi, field.TypeFloat64, value)
_node.Kpi = value
}
if value, ok := dkc.mutation.X(); ok {
_spec.SetField(devicekpi.FieldX, field.TypeFloat64, value)
_node.X = value
}
if value, ok := dkc.mutation.Y(); ok {
_spec.SetField(devicekpi.FieldY, field.TypeFloat64, value)
_node.Y = value
}
if value, ok := dkc.mutation.A(); ok {
_spec.SetField(devicekpi.FieldA, field.TypeFloat64, value)
_node.A = value
}
if value, ok := dkc.mutation.B(); ok {
_spec.SetField(devicekpi.FieldB, field.TypeFloat64, value)
_node.B = value
}
if value, ok := dkc.mutation.WeekKpi(); ok {
_spec.SetField(devicekpi.FieldWeekKpi, field.TypeFloat64, value)
_node.WeekKpi = value
}
if value, ok := dkc.mutation.MonthKpi(); ok {
_spec.SetField(devicekpi.FieldMonthKpi, field.TypeFloat64, value)
_node.MonthKpi = value
}
if value, ok := dkc.mutation.CurrentDay1(); ok {
_spec.SetField(devicekpi.FieldCurrentDay1, field.TypeInt64, value)
_node.CurrentDay1 = value
}
if value, ok := dkc.mutation.CurrentDay7(); ok {
_spec.SetField(devicekpi.FieldCurrentDay7, field.TypeInt64, value)
_node.CurrentDay7 = value
}
if value, ok := dkc.mutation.CurrentDay28(); ok {
_spec.SetField(devicekpi.FieldCurrentDay28, field.TypeInt64, value)
_node.CurrentDay28 = value
}
return _node, _spec
}
func (dkc *DeviceKpiCreate) TableName(s string) *DeviceKpiCreate {
dkc.Table = s
return dkc
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.DeviceKpi.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.DeviceKpiUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func (dkc *DeviceKpiCreate) OnConflict(opts ...sql.ConflictOption) *DeviceKpiUpsertOne {
dkc.conflict = opts
return &DeviceKpiUpsertOne{
create: dkc,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.DeviceKpi.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (dkc *DeviceKpiCreate) OnConflictColumns(columns ...string) *DeviceKpiUpsertOne {
dkc.conflict = append(dkc.conflict, sql.ConflictColumns(columns...))
return &DeviceKpiUpsertOne{
create: dkc,
}
}
type (
// DeviceKpiUpsertOne is the builder for "upsert"-ing
// one DeviceKpi node.
DeviceKpiUpsertOne struct {
create *DeviceKpiCreate
}
// DeviceKpiUpsert is the "OnConflict" setter.
DeviceKpiUpsert struct {
*sql.UpdateSet
}
)
// SetUpdatedAt sets the "updated_at" field.
func (u *DeviceKpiUpsert) SetUpdatedAt(v time.Time) *DeviceKpiUpsert {
u.Set(devicekpi.FieldUpdatedAt, v)
return u
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *DeviceKpiUpsert) UpdateUpdatedAt() *DeviceKpiUpsert {
u.SetExcluded(devicekpi.FieldUpdatedAt)
return u
}
// SetStatus sets the "status" field.
func (u *DeviceKpiUpsert) SetStatus(v uint8) *DeviceKpiUpsert {
u.Set(devicekpi.FieldStatus, v)
return u
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *DeviceKpiUpsert) UpdateStatus() *DeviceKpiUpsert {
u.SetExcluded(devicekpi.FieldStatus)
return u
}
// AddStatus adds v to the "status" field.
func (u *DeviceKpiUpsert) AddStatus(v uint8) *DeviceKpiUpsert {
u.Add(devicekpi.FieldStatus, v)
return u
}
// ClearStatus clears the value of the "status" field.
func (u *DeviceKpiUpsert) ClearStatus() *DeviceKpiUpsert {
u.SetNull(devicekpi.FieldStatus)
return u
}
// SetSort sets the "sort" field.
func (u *DeviceKpiUpsert) SetSort(v uint32) *DeviceKpiUpsert {
u.Set(devicekpi.FieldSort, v)
return u
}
// UpdateSort sets the "sort" field to the value that was provided on create.
func (u *DeviceKpiUpsert) UpdateSort() *DeviceKpiUpsert {
u.SetExcluded(devicekpi.FieldSort)
return u
}
// AddSort adds v to the "sort" field.
func (u *DeviceKpiUpsert) AddSort(v uint32) *DeviceKpiUpsert {
u.Add(devicekpi.FieldSort, v)
return u
}
// SetIotID sets the "iotID" field.
func (u *DeviceKpiUpsert) SetIotID(v string) *DeviceKpiUpsert {
u.Set(devicekpi.FieldIotID, v)
return u
}
// UpdateIotID sets the "iotID" field to the value that was provided on create.
func (u *DeviceKpiUpsert) UpdateIotID() *DeviceKpiUpsert {
u.SetExcluded(devicekpi.FieldIotID)
return u
}
// SetDeviceName sets the "deviceName" field.
func (u *DeviceKpiUpsert) SetDeviceName(v string) *DeviceKpiUpsert {
u.Set(devicekpi.FieldDeviceName, v)
return u
}
// UpdateDeviceName sets the "deviceName" field to the value that was provided on create.
func (u *DeviceKpiUpsert) UpdateDeviceName() *DeviceKpiUpsert {
u.SetExcluded(devicekpi.FieldDeviceName)
return u
}
// SetProductKey sets the "productKey" field.
func (u *DeviceKpiUpsert) SetProductKey(v string) *DeviceKpiUpsert {
u.Set(devicekpi.FieldProductKey, v)
return u
}
// UpdateProductKey sets the "productKey" field to the value that was provided on create.
func (u *DeviceKpiUpsert) UpdateProductKey() *DeviceKpiUpsert {
u.SetExcluded(devicekpi.FieldProductKey)
return u
}
// SetKpi sets the "kpi" field.
func (u *DeviceKpiUpsert) SetKpi(v float64) *DeviceKpiUpsert {
u.Set(devicekpi.FieldKpi, v)
return u
}
// UpdateKpi sets the "kpi" field to the value that was provided on create.
func (u *DeviceKpiUpsert) UpdateKpi() *DeviceKpiUpsert {
u.SetExcluded(devicekpi.FieldKpi)
return u
}
// AddKpi adds v to the "kpi" field.
func (u *DeviceKpiUpsert) AddKpi(v float64) *DeviceKpiUpsert {
u.Add(devicekpi.FieldKpi, v)
return u
}
// ClearKpi clears the value of the "kpi" field.
func (u *DeviceKpiUpsert) ClearKpi() *DeviceKpiUpsert {
u.SetNull(devicekpi.FieldKpi)
return u
}
// SetX sets the "x" field.
func (u *DeviceKpiUpsert) SetX(v float64) *DeviceKpiUpsert {
u.Set(devicekpi.FieldX, v)
return u
}
// UpdateX sets the "x" field to the value that was provided on create.
func (u *DeviceKpiUpsert) UpdateX() *DeviceKpiUpsert {
u.SetExcluded(devicekpi.FieldX)
return u
}
// AddX adds v to the "x" field.
func (u *DeviceKpiUpsert) AddX(v float64) *DeviceKpiUpsert {
u.Add(devicekpi.FieldX, v)
return u
}
// ClearX clears the value of the "x" field.
func (u *DeviceKpiUpsert) ClearX() *DeviceKpiUpsert {
u.SetNull(devicekpi.FieldX)
return u
}
// SetY sets the "y" field.
func (u *DeviceKpiUpsert) SetY(v float64) *DeviceKpiUpsert {
u.Set(devicekpi.FieldY, v)
return u
}
// UpdateY sets the "y" field to the value that was provided on create.
func (u *DeviceKpiUpsert) UpdateY() *DeviceKpiUpsert {
u.SetExcluded(devicekpi.FieldY)
return u
}
// AddY adds v to the "y" field.
func (u *DeviceKpiUpsert) AddY(v float64) *DeviceKpiUpsert {
u.Add(devicekpi.FieldY, v)
return u
}
// ClearY clears the value of the "y" field.
func (u *DeviceKpiUpsert) ClearY() *DeviceKpiUpsert {
u.SetNull(devicekpi.FieldY)
return u
}
// SetA sets the "a" field.
func (u *DeviceKpiUpsert) SetA(v float64) *DeviceKpiUpsert {
u.Set(devicekpi.FieldA, v)
return u
}
// UpdateA sets the "a" field to the value that was provided on create.
func (u *DeviceKpiUpsert) UpdateA() *DeviceKpiUpsert {
u.SetExcluded(devicekpi.FieldA)
return u
}
// AddA adds v to the "a" field.
func (u *DeviceKpiUpsert) AddA(v float64) *DeviceKpiUpsert {
u.Add(devicekpi.FieldA, v)
return u
}
// ClearA clears the value of the "a" field.
func (u *DeviceKpiUpsert) ClearA() *DeviceKpiUpsert {
u.SetNull(devicekpi.FieldA)
return u
}
// SetB sets the "b" field.
func (u *DeviceKpiUpsert) SetB(v float64) *DeviceKpiUpsert {
u.Set(devicekpi.FieldB, v)
return u
}
// UpdateB sets the "b" field to the value that was provided on create.
func (u *DeviceKpiUpsert) UpdateB() *DeviceKpiUpsert {
u.SetExcluded(devicekpi.FieldB)
return u
}
// AddB adds v to the "b" field.
func (u *DeviceKpiUpsert) AddB(v float64) *DeviceKpiUpsert {
u.Add(devicekpi.FieldB, v)
return u
}
// ClearB clears the value of the "b" field.
func (u *DeviceKpiUpsert) ClearB() *DeviceKpiUpsert {
u.SetNull(devicekpi.FieldB)
return u
}
// SetWeekKpi sets the "weekKpi" field.
func (u *DeviceKpiUpsert) SetWeekKpi(v float64) *DeviceKpiUpsert {
u.Set(devicekpi.FieldWeekKpi, v)
return u
}
// UpdateWeekKpi sets the "weekKpi" field to the value that was provided on create.
func (u *DeviceKpiUpsert) UpdateWeekKpi() *DeviceKpiUpsert {
u.SetExcluded(devicekpi.FieldWeekKpi)
return u
}
// AddWeekKpi adds v to the "weekKpi" field.
func (u *DeviceKpiUpsert) AddWeekKpi(v float64) *DeviceKpiUpsert {
u.Add(devicekpi.FieldWeekKpi, v)
return u
}
// ClearWeekKpi clears the value of the "weekKpi" field.
func (u *DeviceKpiUpsert) ClearWeekKpi() *DeviceKpiUpsert {
u.SetNull(devicekpi.FieldWeekKpi)
return u
}
// SetMonthKpi sets the "monthKpi" field.
func (u *DeviceKpiUpsert) SetMonthKpi(v float64) *DeviceKpiUpsert {
u.Set(devicekpi.FieldMonthKpi, v)
return u
}
// UpdateMonthKpi sets the "monthKpi" field to the value that was provided on create.
func (u *DeviceKpiUpsert) UpdateMonthKpi() *DeviceKpiUpsert {
u.SetExcluded(devicekpi.FieldMonthKpi)
return u
}
// AddMonthKpi adds v to the "monthKpi" field.
func (u *DeviceKpiUpsert) AddMonthKpi(v float64) *DeviceKpiUpsert {
u.Add(devicekpi.FieldMonthKpi, v)
return u
}
// ClearMonthKpi clears the value of the "monthKpi" field.
func (u *DeviceKpiUpsert) ClearMonthKpi() *DeviceKpiUpsert {
u.SetNull(devicekpi.FieldMonthKpi)
return u
}
// SetCurrentDay1 sets the "currentDay1" field.
func (u *DeviceKpiUpsert) SetCurrentDay1(v int64) *DeviceKpiUpsert {
u.Set(devicekpi.FieldCurrentDay1, v)
return u
}
// UpdateCurrentDay1 sets the "currentDay1" field to the value that was provided on create.
func (u *DeviceKpiUpsert) UpdateCurrentDay1() *DeviceKpiUpsert {
u.SetExcluded(devicekpi.FieldCurrentDay1)
return u
}
// AddCurrentDay1 adds v to the "currentDay1" field.
func (u *DeviceKpiUpsert) AddCurrentDay1(v int64) *DeviceKpiUpsert {
u.Add(devicekpi.FieldCurrentDay1, v)
return u
}
// ClearCurrentDay1 clears the value of the "currentDay1" field.
func (u *DeviceKpiUpsert) ClearCurrentDay1() *DeviceKpiUpsert {
u.SetNull(devicekpi.FieldCurrentDay1)
return u
}
// SetCurrentDay7 sets the "currentDay7" field.
func (u *DeviceKpiUpsert) SetCurrentDay7(v int64) *DeviceKpiUpsert {
u.Set(devicekpi.FieldCurrentDay7, v)
return u
}
// UpdateCurrentDay7 sets the "currentDay7" field to the value that was provided on create.
func (u *DeviceKpiUpsert) UpdateCurrentDay7() *DeviceKpiUpsert {
u.SetExcluded(devicekpi.FieldCurrentDay7)
return u
}
// AddCurrentDay7 adds v to the "currentDay7" field.
func (u *DeviceKpiUpsert) AddCurrentDay7(v int64) *DeviceKpiUpsert {
u.Add(devicekpi.FieldCurrentDay7, v)
return u
}
// ClearCurrentDay7 clears the value of the "currentDay7" field.
func (u *DeviceKpiUpsert) ClearCurrentDay7() *DeviceKpiUpsert {
u.SetNull(devicekpi.FieldCurrentDay7)
return u
}
// SetCurrentDay28 sets the "currentDay28" field.
func (u *DeviceKpiUpsert) SetCurrentDay28(v int64) *DeviceKpiUpsert {
u.Set(devicekpi.FieldCurrentDay28, v)
return u
}
// UpdateCurrentDay28 sets the "currentDay28" field to the value that was provided on create.
func (u *DeviceKpiUpsert) UpdateCurrentDay28() *DeviceKpiUpsert {
u.SetExcluded(devicekpi.FieldCurrentDay28)
return u
}
// AddCurrentDay28 adds v to the "currentDay28" field.
func (u *DeviceKpiUpsert) AddCurrentDay28(v int64) *DeviceKpiUpsert {
u.Add(devicekpi.FieldCurrentDay28, v)
return u
}
// ClearCurrentDay28 clears the value of the "currentDay28" field.
func (u *DeviceKpiUpsert) ClearCurrentDay28() *DeviceKpiUpsert {
u.SetNull(devicekpi.FieldCurrentDay28)
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.DeviceKpi.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// sql.ResolveWith(func(u *sql.UpdateSet) {
// u.SetIgnore(devicekpi.FieldID)
// }),
// ).
// Exec(ctx)
func (u *DeviceKpiUpsertOne) UpdateNewValues() *DeviceKpiUpsertOne {
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(devicekpi.FieldID)
}
if _, exists := u.create.mutation.CreatedAt(); exists {
s.SetIgnore(devicekpi.FieldCreatedAt)
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.DeviceKpi.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *DeviceKpiUpsertOne) Ignore() *DeviceKpiUpsertOne {
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 *DeviceKpiUpsertOne) DoNothing() *DeviceKpiUpsertOne {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the DeviceKpiCreate.OnConflict
// documentation for more info.
func (u *DeviceKpiUpsertOne) Update(set func(*DeviceKpiUpsert)) *DeviceKpiUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&DeviceKpiUpsert{UpdateSet: update})
}))
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *DeviceKpiUpsertOne) SetUpdatedAt(v time.Time) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *DeviceKpiUpsertOne) UpdateUpdatedAt() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateUpdatedAt()
})
}
// SetStatus sets the "status" field.
func (u *DeviceKpiUpsertOne) SetStatus(v uint8) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetStatus(v)
})
}
// AddStatus adds v to the "status" field.
func (u *DeviceKpiUpsertOne) AddStatus(v uint8) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddStatus(v)
})
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *DeviceKpiUpsertOne) UpdateStatus() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateStatus()
})
}
// ClearStatus clears the value of the "status" field.
func (u *DeviceKpiUpsertOne) ClearStatus() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearStatus()
})
}
// SetSort sets the "sort" field.
func (u *DeviceKpiUpsertOne) SetSort(v uint32) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetSort(v)
})
}
// AddSort adds v to the "sort" field.
func (u *DeviceKpiUpsertOne) AddSort(v uint32) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddSort(v)
})
}
// UpdateSort sets the "sort" field to the value that was provided on create.
func (u *DeviceKpiUpsertOne) UpdateSort() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateSort()
})
}
// SetIotID sets the "iotID" field.
func (u *DeviceKpiUpsertOne) SetIotID(v string) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetIotID(v)
})
}
// UpdateIotID sets the "iotID" field to the value that was provided on create.
func (u *DeviceKpiUpsertOne) UpdateIotID() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateIotID()
})
}
// SetDeviceName sets the "deviceName" field.
func (u *DeviceKpiUpsertOne) SetDeviceName(v string) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetDeviceName(v)
})
}
// UpdateDeviceName sets the "deviceName" field to the value that was provided on create.
func (u *DeviceKpiUpsertOne) UpdateDeviceName() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateDeviceName()
})
}
// SetProductKey sets the "productKey" field.
func (u *DeviceKpiUpsertOne) SetProductKey(v string) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetProductKey(v)
})
}
// UpdateProductKey sets the "productKey" field to the value that was provided on create.
func (u *DeviceKpiUpsertOne) UpdateProductKey() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateProductKey()
})
}
// SetKpi sets the "kpi" field.
func (u *DeviceKpiUpsertOne) SetKpi(v float64) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetKpi(v)
})
}
// AddKpi adds v to the "kpi" field.
func (u *DeviceKpiUpsertOne) AddKpi(v float64) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddKpi(v)
})
}
// UpdateKpi sets the "kpi" field to the value that was provided on create.
func (u *DeviceKpiUpsertOne) UpdateKpi() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateKpi()
})
}
// ClearKpi clears the value of the "kpi" field.
func (u *DeviceKpiUpsertOne) ClearKpi() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearKpi()
})
}
// SetX sets the "x" field.
func (u *DeviceKpiUpsertOne) SetX(v float64) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetX(v)
})
}
// AddX adds v to the "x" field.
func (u *DeviceKpiUpsertOne) AddX(v float64) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddX(v)
})
}
// UpdateX sets the "x" field to the value that was provided on create.
func (u *DeviceKpiUpsertOne) UpdateX() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateX()
})
}
// ClearX clears the value of the "x" field.
func (u *DeviceKpiUpsertOne) ClearX() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearX()
})
}
// SetY sets the "y" field.
func (u *DeviceKpiUpsertOne) SetY(v float64) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetY(v)
})
}
// AddY adds v to the "y" field.
func (u *DeviceKpiUpsertOne) AddY(v float64) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddY(v)
})
}
// UpdateY sets the "y" field to the value that was provided on create.
func (u *DeviceKpiUpsertOne) UpdateY() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateY()
})
}
// ClearY clears the value of the "y" field.
func (u *DeviceKpiUpsertOne) ClearY() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearY()
})
}
// SetA sets the "a" field.
func (u *DeviceKpiUpsertOne) SetA(v float64) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetA(v)
})
}
// AddA adds v to the "a" field.
func (u *DeviceKpiUpsertOne) AddA(v float64) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddA(v)
})
}
// UpdateA sets the "a" field to the value that was provided on create.
func (u *DeviceKpiUpsertOne) UpdateA() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateA()
})
}
// ClearA clears the value of the "a" field.
func (u *DeviceKpiUpsertOne) ClearA() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearA()
})
}
// SetB sets the "b" field.
func (u *DeviceKpiUpsertOne) SetB(v float64) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetB(v)
})
}
// AddB adds v to the "b" field.
func (u *DeviceKpiUpsertOne) AddB(v float64) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddB(v)
})
}
// UpdateB sets the "b" field to the value that was provided on create.
func (u *DeviceKpiUpsertOne) UpdateB() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateB()
})
}
// ClearB clears the value of the "b" field.
func (u *DeviceKpiUpsertOne) ClearB() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearB()
})
}
// SetWeekKpi sets the "weekKpi" field.
func (u *DeviceKpiUpsertOne) SetWeekKpi(v float64) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetWeekKpi(v)
})
}
// AddWeekKpi adds v to the "weekKpi" field.
func (u *DeviceKpiUpsertOne) AddWeekKpi(v float64) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddWeekKpi(v)
})
}
// UpdateWeekKpi sets the "weekKpi" field to the value that was provided on create.
func (u *DeviceKpiUpsertOne) UpdateWeekKpi() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateWeekKpi()
})
}
// ClearWeekKpi clears the value of the "weekKpi" field.
func (u *DeviceKpiUpsertOne) ClearWeekKpi() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearWeekKpi()
})
}
// SetMonthKpi sets the "monthKpi" field.
func (u *DeviceKpiUpsertOne) SetMonthKpi(v float64) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetMonthKpi(v)
})
}
// AddMonthKpi adds v to the "monthKpi" field.
func (u *DeviceKpiUpsertOne) AddMonthKpi(v float64) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddMonthKpi(v)
})
}
// UpdateMonthKpi sets the "monthKpi" field to the value that was provided on create.
func (u *DeviceKpiUpsertOne) UpdateMonthKpi() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateMonthKpi()
})
}
// ClearMonthKpi clears the value of the "monthKpi" field.
func (u *DeviceKpiUpsertOne) ClearMonthKpi() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearMonthKpi()
})
}
// SetCurrentDay1 sets the "currentDay1" field.
func (u *DeviceKpiUpsertOne) SetCurrentDay1(v int64) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetCurrentDay1(v)
})
}
// AddCurrentDay1 adds v to the "currentDay1" field.
func (u *DeviceKpiUpsertOne) AddCurrentDay1(v int64) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddCurrentDay1(v)
})
}
// UpdateCurrentDay1 sets the "currentDay1" field to the value that was provided on create.
func (u *DeviceKpiUpsertOne) UpdateCurrentDay1() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateCurrentDay1()
})
}
// ClearCurrentDay1 clears the value of the "currentDay1" field.
func (u *DeviceKpiUpsertOne) ClearCurrentDay1() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearCurrentDay1()
})
}
// SetCurrentDay7 sets the "currentDay7" field.
func (u *DeviceKpiUpsertOne) SetCurrentDay7(v int64) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetCurrentDay7(v)
})
}
// AddCurrentDay7 adds v to the "currentDay7" field.
func (u *DeviceKpiUpsertOne) AddCurrentDay7(v int64) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddCurrentDay7(v)
})
}
// UpdateCurrentDay7 sets the "currentDay7" field to the value that was provided on create.
func (u *DeviceKpiUpsertOne) UpdateCurrentDay7() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateCurrentDay7()
})
}
// ClearCurrentDay7 clears the value of the "currentDay7" field.
func (u *DeviceKpiUpsertOne) ClearCurrentDay7() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearCurrentDay7()
})
}
// SetCurrentDay28 sets the "currentDay28" field.
func (u *DeviceKpiUpsertOne) SetCurrentDay28(v int64) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetCurrentDay28(v)
})
}
// AddCurrentDay28 adds v to the "currentDay28" field.
func (u *DeviceKpiUpsertOne) AddCurrentDay28(v int64) *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddCurrentDay28(v)
})
}
// UpdateCurrentDay28 sets the "currentDay28" field to the value that was provided on create.
func (u *DeviceKpiUpsertOne) UpdateCurrentDay28() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateCurrentDay28()
})
}
// ClearCurrentDay28 clears the value of the "currentDay28" field.
func (u *DeviceKpiUpsertOne) ClearCurrentDay28() *DeviceKpiUpsertOne {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearCurrentDay28()
})
}
// Exec executes the query.
func (u *DeviceKpiUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for DeviceKpiCreate.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *DeviceKpiUpsertOne) 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 *DeviceKpiUpsertOne) ID(ctx context.Context) (id uint64, err error) {
node, err := u.create.Save(ctx)
if err != nil {
return id, err
}
return node.ID, nil
}
// IDX is like ID, but panics if an error occurs.
func (u *DeviceKpiUpsertOne) IDX(ctx context.Context) uint64 {
id, err := u.ID(ctx)
if err != nil {
panic(err)
}
return id
}
// DeviceKpiCreateBulk is the builder for creating many DeviceKpi entities in bulk.
type DeviceKpiCreateBulk struct {
config
err error
builders []*DeviceKpiCreate
conflict []sql.ConflictOption
}
// Save creates the DeviceKpi entities in the database.
func (dkcb *DeviceKpiCreateBulk) Save(ctx context.Context) ([]*DeviceKpi, error) {
if dkcb.err != nil {
return nil, dkcb.err
}
specs := make([]*sqlgraph.CreateSpec, len(dkcb.builders))
nodes := make([]*DeviceKpi, len(dkcb.builders))
mutators := make([]Mutator, len(dkcb.builders))
for i := range dkcb.builders {
func(i int, root context.Context) {
builder := dkcb.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*DeviceKpiMutation)
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, dkcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
spec.OnConflict = dkcb.conflict
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, dkcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
mutation.id = &nodes[i].ID
if specs[i].ID.Value != nil && nodes[i].ID == 0 {
id := specs[i].ID.Value.(int64)
nodes[i].ID = uint64(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, dkcb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (dkcb *DeviceKpiCreateBulk) SaveX(ctx context.Context) []*DeviceKpi {
v, err := dkcb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (dkcb *DeviceKpiCreateBulk) Exec(ctx context.Context) error {
_, err := dkcb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (dkcb *DeviceKpiCreateBulk) ExecX(ctx context.Context) {
if err := dkcb.Exec(ctx); err != nil {
panic(err)
}
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.DeviceKpi.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.DeviceKpiUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func (dkcb *DeviceKpiCreateBulk) OnConflict(opts ...sql.ConflictOption) *DeviceKpiUpsertBulk {
dkcb.conflict = opts
return &DeviceKpiUpsertBulk{
create: dkcb,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.DeviceKpi.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (dkcb *DeviceKpiCreateBulk) OnConflictColumns(columns ...string) *DeviceKpiUpsertBulk {
dkcb.conflict = append(dkcb.conflict, sql.ConflictColumns(columns...))
return &DeviceKpiUpsertBulk{
create: dkcb,
}
}
// DeviceKpiUpsertBulk is the builder for "upsert"-ing
// a bulk of DeviceKpi nodes.
type DeviceKpiUpsertBulk struct {
create *DeviceKpiCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.DeviceKpi.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// sql.ResolveWith(func(u *sql.UpdateSet) {
// u.SetIgnore(devicekpi.FieldID)
// }),
// ).
// Exec(ctx)
func (u *DeviceKpiUpsertBulk) UpdateNewValues() *DeviceKpiUpsertBulk {
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(devicekpi.FieldID)
}
if _, exists := b.mutation.CreatedAt(); exists {
s.SetIgnore(devicekpi.FieldCreatedAt)
}
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.DeviceKpi.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *DeviceKpiUpsertBulk) Ignore() *DeviceKpiUpsertBulk {
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 *DeviceKpiUpsertBulk) DoNothing() *DeviceKpiUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the DeviceKpiCreateBulk.OnConflict
// documentation for more info.
func (u *DeviceKpiUpsertBulk) Update(set func(*DeviceKpiUpsert)) *DeviceKpiUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&DeviceKpiUpsert{UpdateSet: update})
}))
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *DeviceKpiUpsertBulk) SetUpdatedAt(v time.Time) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *DeviceKpiUpsertBulk) UpdateUpdatedAt() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateUpdatedAt()
})
}
// SetStatus sets the "status" field.
func (u *DeviceKpiUpsertBulk) SetStatus(v uint8) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetStatus(v)
})
}
// AddStatus adds v to the "status" field.
func (u *DeviceKpiUpsertBulk) AddStatus(v uint8) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddStatus(v)
})
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *DeviceKpiUpsertBulk) UpdateStatus() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateStatus()
})
}
// ClearStatus clears the value of the "status" field.
func (u *DeviceKpiUpsertBulk) ClearStatus() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearStatus()
})
}
// SetSort sets the "sort" field.
func (u *DeviceKpiUpsertBulk) SetSort(v uint32) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetSort(v)
})
}
// AddSort adds v to the "sort" field.
func (u *DeviceKpiUpsertBulk) AddSort(v uint32) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddSort(v)
})
}
// UpdateSort sets the "sort" field to the value that was provided on create.
func (u *DeviceKpiUpsertBulk) UpdateSort() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateSort()
})
}
// SetIotID sets the "iotID" field.
func (u *DeviceKpiUpsertBulk) SetIotID(v string) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetIotID(v)
})
}
// UpdateIotID sets the "iotID" field to the value that was provided on create.
func (u *DeviceKpiUpsertBulk) UpdateIotID() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateIotID()
})
}
// SetDeviceName sets the "deviceName" field.
func (u *DeviceKpiUpsertBulk) SetDeviceName(v string) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetDeviceName(v)
})
}
// UpdateDeviceName sets the "deviceName" field to the value that was provided on create.
func (u *DeviceKpiUpsertBulk) UpdateDeviceName() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateDeviceName()
})
}
// SetProductKey sets the "productKey" field.
func (u *DeviceKpiUpsertBulk) SetProductKey(v string) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetProductKey(v)
})
}
// UpdateProductKey sets the "productKey" field to the value that was provided on create.
func (u *DeviceKpiUpsertBulk) UpdateProductKey() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateProductKey()
})
}
// SetKpi sets the "kpi" field.
func (u *DeviceKpiUpsertBulk) SetKpi(v float64) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetKpi(v)
})
}
// AddKpi adds v to the "kpi" field.
func (u *DeviceKpiUpsertBulk) AddKpi(v float64) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddKpi(v)
})
}
// UpdateKpi sets the "kpi" field to the value that was provided on create.
func (u *DeviceKpiUpsertBulk) UpdateKpi() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateKpi()
})
}
// ClearKpi clears the value of the "kpi" field.
func (u *DeviceKpiUpsertBulk) ClearKpi() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearKpi()
})
}
// SetX sets the "x" field.
func (u *DeviceKpiUpsertBulk) SetX(v float64) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetX(v)
})
}
// AddX adds v to the "x" field.
func (u *DeviceKpiUpsertBulk) AddX(v float64) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddX(v)
})
}
// UpdateX sets the "x" field to the value that was provided on create.
func (u *DeviceKpiUpsertBulk) UpdateX() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateX()
})
}
// ClearX clears the value of the "x" field.
func (u *DeviceKpiUpsertBulk) ClearX() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearX()
})
}
// SetY sets the "y" field.
func (u *DeviceKpiUpsertBulk) SetY(v float64) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetY(v)
})
}
// AddY adds v to the "y" field.
func (u *DeviceKpiUpsertBulk) AddY(v float64) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddY(v)
})
}
// UpdateY sets the "y" field to the value that was provided on create.
func (u *DeviceKpiUpsertBulk) UpdateY() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateY()
})
}
// ClearY clears the value of the "y" field.
func (u *DeviceKpiUpsertBulk) ClearY() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearY()
})
}
// SetA sets the "a" field.
func (u *DeviceKpiUpsertBulk) SetA(v float64) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetA(v)
})
}
// AddA adds v to the "a" field.
func (u *DeviceKpiUpsertBulk) AddA(v float64) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddA(v)
})
}
// UpdateA sets the "a" field to the value that was provided on create.
func (u *DeviceKpiUpsertBulk) UpdateA() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateA()
})
}
// ClearA clears the value of the "a" field.
func (u *DeviceKpiUpsertBulk) ClearA() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearA()
})
}
// SetB sets the "b" field.
func (u *DeviceKpiUpsertBulk) SetB(v float64) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetB(v)
})
}
// AddB adds v to the "b" field.
func (u *DeviceKpiUpsertBulk) AddB(v float64) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddB(v)
})
}
// UpdateB sets the "b" field to the value that was provided on create.
func (u *DeviceKpiUpsertBulk) UpdateB() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateB()
})
}
// ClearB clears the value of the "b" field.
func (u *DeviceKpiUpsertBulk) ClearB() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearB()
})
}
// SetWeekKpi sets the "weekKpi" field.
func (u *DeviceKpiUpsertBulk) SetWeekKpi(v float64) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetWeekKpi(v)
})
}
// AddWeekKpi adds v to the "weekKpi" field.
func (u *DeviceKpiUpsertBulk) AddWeekKpi(v float64) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddWeekKpi(v)
})
}
// UpdateWeekKpi sets the "weekKpi" field to the value that was provided on create.
func (u *DeviceKpiUpsertBulk) UpdateWeekKpi() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateWeekKpi()
})
}
// ClearWeekKpi clears the value of the "weekKpi" field.
func (u *DeviceKpiUpsertBulk) ClearWeekKpi() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearWeekKpi()
})
}
// SetMonthKpi sets the "monthKpi" field.
func (u *DeviceKpiUpsertBulk) SetMonthKpi(v float64) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetMonthKpi(v)
})
}
// AddMonthKpi adds v to the "monthKpi" field.
func (u *DeviceKpiUpsertBulk) AddMonthKpi(v float64) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddMonthKpi(v)
})
}
// UpdateMonthKpi sets the "monthKpi" field to the value that was provided on create.
func (u *DeviceKpiUpsertBulk) UpdateMonthKpi() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateMonthKpi()
})
}
// ClearMonthKpi clears the value of the "monthKpi" field.
func (u *DeviceKpiUpsertBulk) ClearMonthKpi() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearMonthKpi()
})
}
// SetCurrentDay1 sets the "currentDay1" field.
func (u *DeviceKpiUpsertBulk) SetCurrentDay1(v int64) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetCurrentDay1(v)
})
}
// AddCurrentDay1 adds v to the "currentDay1" field.
func (u *DeviceKpiUpsertBulk) AddCurrentDay1(v int64) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddCurrentDay1(v)
})
}
// UpdateCurrentDay1 sets the "currentDay1" field to the value that was provided on create.
func (u *DeviceKpiUpsertBulk) UpdateCurrentDay1() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateCurrentDay1()
})
}
// ClearCurrentDay1 clears the value of the "currentDay1" field.
func (u *DeviceKpiUpsertBulk) ClearCurrentDay1() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearCurrentDay1()
})
}
// SetCurrentDay7 sets the "currentDay7" field.
func (u *DeviceKpiUpsertBulk) SetCurrentDay7(v int64) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetCurrentDay7(v)
})
}
// AddCurrentDay7 adds v to the "currentDay7" field.
func (u *DeviceKpiUpsertBulk) AddCurrentDay7(v int64) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddCurrentDay7(v)
})
}
// UpdateCurrentDay7 sets the "currentDay7" field to the value that was provided on create.
func (u *DeviceKpiUpsertBulk) UpdateCurrentDay7() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateCurrentDay7()
})
}
// ClearCurrentDay7 clears the value of the "currentDay7" field.
func (u *DeviceKpiUpsertBulk) ClearCurrentDay7() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearCurrentDay7()
})
}
// SetCurrentDay28 sets the "currentDay28" field.
func (u *DeviceKpiUpsertBulk) SetCurrentDay28(v int64) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.SetCurrentDay28(v)
})
}
// AddCurrentDay28 adds v to the "currentDay28" field.
func (u *DeviceKpiUpsertBulk) AddCurrentDay28(v int64) *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.AddCurrentDay28(v)
})
}
// UpdateCurrentDay28 sets the "currentDay28" field to the value that was provided on create.
func (u *DeviceKpiUpsertBulk) UpdateCurrentDay28() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.UpdateCurrentDay28()
})
}
// ClearCurrentDay28 clears the value of the "currentDay28" field.
func (u *DeviceKpiUpsertBulk) ClearCurrentDay28() *DeviceKpiUpsertBulk {
return u.Update(func(s *DeviceKpiUpsert) {
s.ClearCurrentDay28()
})
}
// Exec executes the query.
func (u *DeviceKpiUpsertBulk) 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 DeviceKpiCreateBulk instead", i)
}
}
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for DeviceKpiCreateBulk.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *DeviceKpiUpsertBulk) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}
Go
1
https://gitee.com/yuLingNet/simple-iot-data-rpc.git
git@gitee.com:yuLingNet/simple-iot-data-rpc.git
yuLingNet
simple-iot-data-rpc
simple-iot-data-rpc
39cb53be4684

搜索帮助

53164aa7 5694891 3bd8fe86 5694891