3 Star 0 Fork 0

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

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
client.go 59.63 KB
一键复制 编辑 原始数据 按行查看 历史
HienGee 提交于 2024-04-26 11:27 . init
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"log"
"reflect"
"gitee.com/yuLingNet/simple-iot-data-rpc/ent/migrate"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
"gitee.com/yuLingNet/simple-iot-data-rpc/ent/deviceduration"
"gitee.com/yuLingNet/simple-iot-data-rpc/ent/devicedurationelephant"
"gitee.com/yuLingNet/simple-iot-data-rpc/ent/deviceevent"
"gitee.com/yuLingNet/simple-iot-data-rpc/ent/devicekpi"
"gitee.com/yuLingNet/simple-iot-data-rpc/ent/deviceofflinetime"
"gitee.com/yuLingNet/simple-iot-data-rpc/ent/deviceonlinetime"
"gitee.com/yuLingNet/simple-iot-data-rpc/ent/deviceontimedaily"
"gitee.com/yuLingNet/simple-iot-data-rpc/ent/deviceupstercycle"
"gitee.com/yuLingNet/simple-iot-data-rpc/ent/deviceupsterstatistics"
stdsql "database/sql"
)
// Client is the client that holds all ent builders.
type Client struct {
config
// Schema is the client for creating, migrating and dropping schema.
Schema *migrate.Schema
// DeviceDuration is the client for interacting with the DeviceDuration builders.
DeviceDuration *DeviceDurationClient
// DeviceDurationElephant is the client for interacting with the DeviceDurationElephant builders.
DeviceDurationElephant *DeviceDurationElephantClient
// DeviceEvent is the client for interacting with the DeviceEvent builders.
DeviceEvent *DeviceEventClient
// DeviceKpi is the client for interacting with the DeviceKpi builders.
DeviceKpi *DeviceKpiClient
// DeviceOfflineTime is the client for interacting with the DeviceOfflineTime builders.
DeviceOfflineTime *DeviceOfflineTimeClient
// DeviceOnTimeDaily is the client for interacting with the DeviceOnTimeDaily builders.
DeviceOnTimeDaily *DeviceOnTimeDailyClient
// DeviceOnlineTime is the client for interacting with the DeviceOnlineTime builders.
DeviceOnlineTime *DeviceOnlineTimeClient
// DeviceUpsterCycle is the client for interacting with the DeviceUpsterCycle builders.
DeviceUpsterCycle *DeviceUpsterCycleClient
// DeviceUpsterStatistics is the client for interacting with the DeviceUpsterStatistics builders.
DeviceUpsterStatistics *DeviceUpsterStatisticsClient
}
// NewClient creates a new client configured with the given options.
func NewClient(opts ...Option) *Client {
client := &Client{config: newConfig(opts...)}
client.init()
return client
}
func (c *Client) init() {
c.Schema = migrate.NewSchema(c.driver)
c.DeviceDuration = NewDeviceDurationClient(c.config)
c.DeviceDurationElephant = NewDeviceDurationElephantClient(c.config)
c.DeviceEvent = NewDeviceEventClient(c.config)
c.DeviceKpi = NewDeviceKpiClient(c.config)
c.DeviceOfflineTime = NewDeviceOfflineTimeClient(c.config)
c.DeviceOnTimeDaily = NewDeviceOnTimeDailyClient(c.config)
c.DeviceOnlineTime = NewDeviceOnlineTimeClient(c.config)
c.DeviceUpsterCycle = NewDeviceUpsterCycleClient(c.config)
c.DeviceUpsterStatistics = NewDeviceUpsterStatisticsClient(c.config)
}
type (
// config is the configuration for the client and its builder.
config struct {
// driver used for executing database requests.
driver dialect.Driver
// debug enable a debug logging.
debug bool
// log used for logging on debug mode.
log func(...any)
// hooks to execute on mutations.
hooks *hooks
// interceptors to execute on queries.
inters *inters
}
// Option function to configure the client.
Option func(*config)
)
// newConfig creates a new config for the client.
func newConfig(opts ...Option) config {
cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}}
cfg.options(opts...)
return cfg
}
// options applies the options on the config object.
func (c *config) options(opts ...Option) {
for _, opt := range opts {
opt(c)
}
if c.debug {
c.driver = dialect.Debug(c.driver, c.log)
}
}
// Debug enables debug logging on the ent.Driver.
func Debug() Option {
return func(c *config) {
c.debug = true
}
}
// Log sets the logging function for debug mode.
func Log(fn func(...any)) Option {
return func(c *config) {
c.log = fn
}
}
// Driver configures the client driver.
func Driver(driver dialect.Driver) Option {
return func(c *config) {
c.driver = driver
}
}
// Open opens a database/sql.DB specified by the driver name and
// the data source name, and returns a new client attached to it.
// Optional parameters can be added for configuring the client.
func Open(driverName, dataSourceName string, options ...Option) (*Client, error) {
switch driverName {
case dialect.MySQL, dialect.Postgres, dialect.SQLite:
drv, err := sql.Open(driverName, dataSourceName)
if err != nil {
return nil, err
}
return NewClient(append(options, Driver(drv))...), nil
default:
return nil, fmt.Errorf("unsupported driver: %q", driverName)
}
}
// ErrTxStarted is returned when trying to start a new transaction from a transactional client.
var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction")
// Tx returns a new transactional client. The provided context
// is used until the transaction is committed or rolled back.
func (c *Client) Tx(ctx context.Context) (*Tx, error) {
if _, ok := c.driver.(*txDriver); ok {
return nil, ErrTxStarted
}
tx, err := newTx(ctx, c.driver)
if err != nil {
return nil, fmt.Errorf("ent: starting a transaction: %w", err)
}
cfg := c.config
cfg.driver = tx
return &Tx{
ctx: ctx,
config: cfg,
DeviceDuration: NewDeviceDurationClient(cfg),
DeviceDurationElephant: NewDeviceDurationElephantClient(cfg),
DeviceEvent: NewDeviceEventClient(cfg),
DeviceKpi: NewDeviceKpiClient(cfg),
DeviceOfflineTime: NewDeviceOfflineTimeClient(cfg),
DeviceOnTimeDaily: NewDeviceOnTimeDailyClient(cfg),
DeviceOnlineTime: NewDeviceOnlineTimeClient(cfg),
DeviceUpsterCycle: NewDeviceUpsterCycleClient(cfg),
DeviceUpsterStatistics: NewDeviceUpsterStatisticsClient(cfg),
}, nil
}
// BeginTx returns a transactional client with specified options.
func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
if _, ok := c.driver.(*txDriver); ok {
return nil, errors.New("ent: cannot start a transaction within a transaction")
}
tx, err := c.driver.(interface {
BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
}).BeginTx(ctx, opts)
if err != nil {
return nil, fmt.Errorf("ent: starting a transaction: %w", err)
}
cfg := c.config
cfg.driver = &txDriver{tx: tx, drv: c.driver}
return &Tx{
ctx: ctx,
config: cfg,
DeviceDuration: NewDeviceDurationClient(cfg),
DeviceDurationElephant: NewDeviceDurationElephantClient(cfg),
DeviceEvent: NewDeviceEventClient(cfg),
DeviceKpi: NewDeviceKpiClient(cfg),
DeviceOfflineTime: NewDeviceOfflineTimeClient(cfg),
DeviceOnTimeDaily: NewDeviceOnTimeDailyClient(cfg),
DeviceOnlineTime: NewDeviceOnlineTimeClient(cfg),
DeviceUpsterCycle: NewDeviceUpsterCycleClient(cfg),
DeviceUpsterStatistics: NewDeviceUpsterStatisticsClient(cfg),
}, nil
}
// Debug returns a new debug-client. It's used to get verbose logging on specific operations.
//
// client.Debug().
// DeviceDuration.
// Query().
// Count(ctx)
func (c *Client) Debug() *Client {
if c.debug {
return c
}
cfg := c.config
cfg.driver = dialect.Debug(c.driver, c.log)
client := &Client{config: cfg}
client.init()
return client
}
// Close closes the database connection and prevents new queries from starting.
func (c *Client) Close() error {
return c.driver.Close()
}
// Use adds the mutation hooks to all the entity clients.
// In order to add hooks to a specific client, call: `client.Node.Use(...)`.
func (c *Client) Use(hooks ...Hook) {
for _, n := range []interface{ Use(...Hook) }{
c.DeviceDuration, c.DeviceDurationElephant, c.DeviceEvent, c.DeviceKpi,
c.DeviceOfflineTime, c.DeviceOnTimeDaily, c.DeviceOnlineTime,
c.DeviceUpsterCycle, c.DeviceUpsterStatistics,
} {
n.Use(hooks...)
}
}
// Intercept adds the query interceptors to all the entity clients.
// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
func (c *Client) Intercept(interceptors ...Interceptor) {
for _, n := range []interface{ Intercept(...Interceptor) }{
c.DeviceDuration, c.DeviceDurationElephant, c.DeviceEvent, c.DeviceKpi,
c.DeviceOfflineTime, c.DeviceOnTimeDaily, c.DeviceOnlineTime,
c.DeviceUpsterCycle, c.DeviceUpsterStatistics,
} {
n.Intercept(interceptors...)
}
}
// Mutate implements the ent.Mutator interface.
func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
switch m := m.(type) {
case *DeviceDurationMutation:
return c.DeviceDuration.mutate(ctx, m)
case *DeviceDurationElephantMutation:
return c.DeviceDurationElephant.mutate(ctx, m)
case *DeviceEventMutation:
return c.DeviceEvent.mutate(ctx, m)
case *DeviceKpiMutation:
return c.DeviceKpi.mutate(ctx, m)
case *DeviceOfflineTimeMutation:
return c.DeviceOfflineTime.mutate(ctx, m)
case *DeviceOnTimeDailyMutation:
return c.DeviceOnTimeDaily.mutate(ctx, m)
case *DeviceOnlineTimeMutation:
return c.DeviceOnlineTime.mutate(ctx, m)
case *DeviceUpsterCycleMutation:
return c.DeviceUpsterCycle.mutate(ctx, m)
case *DeviceUpsterStatisticsMutation:
return c.DeviceUpsterStatistics.mutate(ctx, m)
default:
return nil, fmt.Errorf("ent: unknown mutation type %T", m)
}
}
// DeviceDurationClient is a client for the DeviceDuration schema.
type DeviceDurationClient struct {
config
}
// NewDeviceDurationClient returns a client for the DeviceDuration from the given config.
func NewDeviceDurationClient(c config) *DeviceDurationClient {
return &DeviceDurationClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `deviceduration.Hooks(f(g(h())))`.
func (c *DeviceDurationClient) Use(hooks ...Hook) {
c.hooks.DeviceDuration = append(c.hooks.DeviceDuration, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `deviceduration.Intercept(f(g(h())))`.
func (c *DeviceDurationClient) Intercept(interceptors ...Interceptor) {
c.inters.DeviceDuration = append(c.inters.DeviceDuration, interceptors...)
}
// Create returns a builder for creating a DeviceDuration entity.
func (c *DeviceDurationClient) Create() *DeviceDurationCreate {
mutation := newDeviceDurationMutation(c.config, OpCreate)
return &DeviceDurationCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of DeviceDuration entities.
func (c *DeviceDurationClient) CreateBulk(builders ...*DeviceDurationCreate) *DeviceDurationCreateBulk {
return &DeviceDurationCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *DeviceDurationClient) MapCreateBulk(slice any, setFunc func(*DeviceDurationCreate, int)) *DeviceDurationCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &DeviceDurationCreateBulk{err: fmt.Errorf("calling to DeviceDurationClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*DeviceDurationCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &DeviceDurationCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for DeviceDuration.
func (c *DeviceDurationClient) Update() *DeviceDurationUpdate {
mutation := newDeviceDurationMutation(c.config, OpUpdate)
return &DeviceDurationUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *DeviceDurationClient) UpdateOne(dd *DeviceDuration) *DeviceDurationUpdateOne {
mutation := newDeviceDurationMutation(c.config, OpUpdateOne, withDeviceDuration(dd))
return &DeviceDurationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *DeviceDurationClient) UpdateOneID(id uint64) *DeviceDurationUpdateOne {
mutation := newDeviceDurationMutation(c.config, OpUpdateOne, withDeviceDurationID(id))
return &DeviceDurationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for DeviceDuration.
func (c *DeviceDurationClient) Delete() *DeviceDurationDelete {
mutation := newDeviceDurationMutation(c.config, OpDelete)
return &DeviceDurationDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *DeviceDurationClient) DeleteOne(dd *DeviceDuration) *DeviceDurationDeleteOne {
return c.DeleteOneID(dd.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *DeviceDurationClient) DeleteOneID(id uint64) *DeviceDurationDeleteOne {
builder := c.Delete().Where(deviceduration.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &DeviceDurationDeleteOne{builder}
}
// Query returns a query builder for DeviceDuration.
func (c *DeviceDurationClient) Query() *DeviceDurationQuery {
return &DeviceDurationQuery{
config: c.config,
ctx: &QueryContext{Type: TypeDeviceDuration},
inters: c.Interceptors(),
}
}
// Get returns a DeviceDuration entity by its id.
func (c *DeviceDurationClient) Get(ctx context.Context, id uint64) (*DeviceDuration, error) {
return c.Query().Where(deviceduration.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *DeviceDurationClient) GetX(ctx context.Context, id uint64) *DeviceDuration {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *DeviceDurationClient) Hooks() []Hook {
return c.hooks.DeviceDuration
}
// Interceptors returns the client interceptors.
func (c *DeviceDurationClient) Interceptors() []Interceptor {
return c.inters.DeviceDuration
}
func (c *DeviceDurationClient) mutate(ctx context.Context, m *DeviceDurationMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&DeviceDurationCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&DeviceDurationUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&DeviceDurationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&DeviceDurationDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown DeviceDuration mutation op: %q", m.Op())
}
}
// DeviceDurationElephantClient is a client for the DeviceDurationElephant schema.
type DeviceDurationElephantClient struct {
config
}
// NewDeviceDurationElephantClient returns a client for the DeviceDurationElephant from the given config.
func NewDeviceDurationElephantClient(c config) *DeviceDurationElephantClient {
return &DeviceDurationElephantClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `devicedurationelephant.Hooks(f(g(h())))`.
func (c *DeviceDurationElephantClient) Use(hooks ...Hook) {
c.hooks.DeviceDurationElephant = append(c.hooks.DeviceDurationElephant, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `devicedurationelephant.Intercept(f(g(h())))`.
func (c *DeviceDurationElephantClient) Intercept(interceptors ...Interceptor) {
c.inters.DeviceDurationElephant = append(c.inters.DeviceDurationElephant, interceptors...)
}
// Create returns a builder for creating a DeviceDurationElephant entity.
func (c *DeviceDurationElephantClient) Create() *DeviceDurationElephantCreate {
mutation := newDeviceDurationElephantMutation(c.config, OpCreate)
return &DeviceDurationElephantCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of DeviceDurationElephant entities.
func (c *DeviceDurationElephantClient) CreateBulk(builders ...*DeviceDurationElephantCreate) *DeviceDurationElephantCreateBulk {
return &DeviceDurationElephantCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *DeviceDurationElephantClient) MapCreateBulk(slice any, setFunc func(*DeviceDurationElephantCreate, int)) *DeviceDurationElephantCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &DeviceDurationElephantCreateBulk{err: fmt.Errorf("calling to DeviceDurationElephantClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*DeviceDurationElephantCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &DeviceDurationElephantCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for DeviceDurationElephant.
func (c *DeviceDurationElephantClient) Update() *DeviceDurationElephantUpdate {
mutation := newDeviceDurationElephantMutation(c.config, OpUpdate)
return &DeviceDurationElephantUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *DeviceDurationElephantClient) UpdateOne(dde *DeviceDurationElephant) *DeviceDurationElephantUpdateOne {
mutation := newDeviceDurationElephantMutation(c.config, OpUpdateOne, withDeviceDurationElephant(dde))
return &DeviceDurationElephantUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *DeviceDurationElephantClient) UpdateOneID(id uint64) *DeviceDurationElephantUpdateOne {
mutation := newDeviceDurationElephantMutation(c.config, OpUpdateOne, withDeviceDurationElephantID(id))
return &DeviceDurationElephantUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for DeviceDurationElephant.
func (c *DeviceDurationElephantClient) Delete() *DeviceDurationElephantDelete {
mutation := newDeviceDurationElephantMutation(c.config, OpDelete)
return &DeviceDurationElephantDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *DeviceDurationElephantClient) DeleteOne(dde *DeviceDurationElephant) *DeviceDurationElephantDeleteOne {
return c.DeleteOneID(dde.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *DeviceDurationElephantClient) DeleteOneID(id uint64) *DeviceDurationElephantDeleteOne {
builder := c.Delete().Where(devicedurationelephant.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &DeviceDurationElephantDeleteOne{builder}
}
// Query returns a query builder for DeviceDurationElephant.
func (c *DeviceDurationElephantClient) Query() *DeviceDurationElephantQuery {
return &DeviceDurationElephantQuery{
config: c.config,
ctx: &QueryContext{Type: TypeDeviceDurationElephant},
inters: c.Interceptors(),
}
}
// Get returns a DeviceDurationElephant entity by its id.
func (c *DeviceDurationElephantClient) Get(ctx context.Context, id uint64) (*DeviceDurationElephant, error) {
return c.Query().Where(devicedurationelephant.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *DeviceDurationElephantClient) GetX(ctx context.Context, id uint64) *DeviceDurationElephant {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *DeviceDurationElephantClient) Hooks() []Hook {
return c.hooks.DeviceDurationElephant
}
// Interceptors returns the client interceptors.
func (c *DeviceDurationElephantClient) Interceptors() []Interceptor {
return c.inters.DeviceDurationElephant
}
func (c *DeviceDurationElephantClient) mutate(ctx context.Context, m *DeviceDurationElephantMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&DeviceDurationElephantCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&DeviceDurationElephantUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&DeviceDurationElephantUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&DeviceDurationElephantDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown DeviceDurationElephant mutation op: %q", m.Op())
}
}
// DeviceEventClient is a client for the DeviceEvent schema.
type DeviceEventClient struct {
config
}
// NewDeviceEventClient returns a client for the DeviceEvent from the given config.
func NewDeviceEventClient(c config) *DeviceEventClient {
return &DeviceEventClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `deviceevent.Hooks(f(g(h())))`.
func (c *DeviceEventClient) Use(hooks ...Hook) {
c.hooks.DeviceEvent = append(c.hooks.DeviceEvent, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `deviceevent.Intercept(f(g(h())))`.
func (c *DeviceEventClient) Intercept(interceptors ...Interceptor) {
c.inters.DeviceEvent = append(c.inters.DeviceEvent, interceptors...)
}
// Create returns a builder for creating a DeviceEvent entity.
func (c *DeviceEventClient) Create() *DeviceEventCreate {
mutation := newDeviceEventMutation(c.config, OpCreate)
return &DeviceEventCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of DeviceEvent entities.
func (c *DeviceEventClient) CreateBulk(builders ...*DeviceEventCreate) *DeviceEventCreateBulk {
return &DeviceEventCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *DeviceEventClient) MapCreateBulk(slice any, setFunc func(*DeviceEventCreate, int)) *DeviceEventCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &DeviceEventCreateBulk{err: fmt.Errorf("calling to DeviceEventClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*DeviceEventCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &DeviceEventCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for DeviceEvent.
func (c *DeviceEventClient) Update() *DeviceEventUpdate {
mutation := newDeviceEventMutation(c.config, OpUpdate)
return &DeviceEventUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *DeviceEventClient) UpdateOne(de *DeviceEvent) *DeviceEventUpdateOne {
mutation := newDeviceEventMutation(c.config, OpUpdateOne, withDeviceEvent(de))
return &DeviceEventUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *DeviceEventClient) UpdateOneID(id uint64) *DeviceEventUpdateOne {
mutation := newDeviceEventMutation(c.config, OpUpdateOne, withDeviceEventID(id))
return &DeviceEventUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for DeviceEvent.
func (c *DeviceEventClient) Delete() *DeviceEventDelete {
mutation := newDeviceEventMutation(c.config, OpDelete)
return &DeviceEventDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *DeviceEventClient) DeleteOne(de *DeviceEvent) *DeviceEventDeleteOne {
return c.DeleteOneID(de.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *DeviceEventClient) DeleteOneID(id uint64) *DeviceEventDeleteOne {
builder := c.Delete().Where(deviceevent.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &DeviceEventDeleteOne{builder}
}
// Query returns a query builder for DeviceEvent.
func (c *DeviceEventClient) Query() *DeviceEventQuery {
return &DeviceEventQuery{
config: c.config,
ctx: &QueryContext{Type: TypeDeviceEvent},
inters: c.Interceptors(),
}
}
// Get returns a DeviceEvent entity by its id.
func (c *DeviceEventClient) Get(ctx context.Context, id uint64) (*DeviceEvent, error) {
return c.Query().Where(deviceevent.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *DeviceEventClient) GetX(ctx context.Context, id uint64) *DeviceEvent {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *DeviceEventClient) Hooks() []Hook {
return c.hooks.DeviceEvent
}
// Interceptors returns the client interceptors.
func (c *DeviceEventClient) Interceptors() []Interceptor {
return c.inters.DeviceEvent
}
func (c *DeviceEventClient) mutate(ctx context.Context, m *DeviceEventMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&DeviceEventCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&DeviceEventUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&DeviceEventUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&DeviceEventDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown DeviceEvent mutation op: %q", m.Op())
}
}
// DeviceKpiClient is a client for the DeviceKpi schema.
type DeviceKpiClient struct {
config
}
// NewDeviceKpiClient returns a client for the DeviceKpi from the given config.
func NewDeviceKpiClient(c config) *DeviceKpiClient {
return &DeviceKpiClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `devicekpi.Hooks(f(g(h())))`.
func (c *DeviceKpiClient) Use(hooks ...Hook) {
c.hooks.DeviceKpi = append(c.hooks.DeviceKpi, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `devicekpi.Intercept(f(g(h())))`.
func (c *DeviceKpiClient) Intercept(interceptors ...Interceptor) {
c.inters.DeviceKpi = append(c.inters.DeviceKpi, interceptors...)
}
// Create returns a builder for creating a DeviceKpi entity.
func (c *DeviceKpiClient) Create() *DeviceKpiCreate {
mutation := newDeviceKpiMutation(c.config, OpCreate)
return &DeviceKpiCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of DeviceKpi entities.
func (c *DeviceKpiClient) CreateBulk(builders ...*DeviceKpiCreate) *DeviceKpiCreateBulk {
return &DeviceKpiCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *DeviceKpiClient) MapCreateBulk(slice any, setFunc func(*DeviceKpiCreate, int)) *DeviceKpiCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &DeviceKpiCreateBulk{err: fmt.Errorf("calling to DeviceKpiClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*DeviceKpiCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &DeviceKpiCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for DeviceKpi.
func (c *DeviceKpiClient) Update() *DeviceKpiUpdate {
mutation := newDeviceKpiMutation(c.config, OpUpdate)
return &DeviceKpiUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *DeviceKpiClient) UpdateOne(dk *DeviceKpi) *DeviceKpiUpdateOne {
mutation := newDeviceKpiMutation(c.config, OpUpdateOne, withDeviceKpi(dk))
return &DeviceKpiUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *DeviceKpiClient) UpdateOneID(id uint64) *DeviceKpiUpdateOne {
mutation := newDeviceKpiMutation(c.config, OpUpdateOne, withDeviceKpiID(id))
return &DeviceKpiUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for DeviceKpi.
func (c *DeviceKpiClient) Delete() *DeviceKpiDelete {
mutation := newDeviceKpiMutation(c.config, OpDelete)
return &DeviceKpiDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *DeviceKpiClient) DeleteOne(dk *DeviceKpi) *DeviceKpiDeleteOne {
return c.DeleteOneID(dk.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *DeviceKpiClient) DeleteOneID(id uint64) *DeviceKpiDeleteOne {
builder := c.Delete().Where(devicekpi.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &DeviceKpiDeleteOne{builder}
}
// Query returns a query builder for DeviceKpi.
func (c *DeviceKpiClient) Query() *DeviceKpiQuery {
return &DeviceKpiQuery{
config: c.config,
ctx: &QueryContext{Type: TypeDeviceKpi},
inters: c.Interceptors(),
}
}
// Get returns a DeviceKpi entity by its id.
func (c *DeviceKpiClient) Get(ctx context.Context, id uint64) (*DeviceKpi, error) {
return c.Query().Where(devicekpi.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *DeviceKpiClient) GetX(ctx context.Context, id uint64) *DeviceKpi {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *DeviceKpiClient) Hooks() []Hook {
return c.hooks.DeviceKpi
}
// Interceptors returns the client interceptors.
func (c *DeviceKpiClient) Interceptors() []Interceptor {
return c.inters.DeviceKpi
}
func (c *DeviceKpiClient) mutate(ctx context.Context, m *DeviceKpiMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&DeviceKpiCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&DeviceKpiUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&DeviceKpiUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&DeviceKpiDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown DeviceKpi mutation op: %q", m.Op())
}
}
// DeviceOfflineTimeClient is a client for the DeviceOfflineTime schema.
type DeviceOfflineTimeClient struct {
config
}
// NewDeviceOfflineTimeClient returns a client for the DeviceOfflineTime from the given config.
func NewDeviceOfflineTimeClient(c config) *DeviceOfflineTimeClient {
return &DeviceOfflineTimeClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `deviceofflinetime.Hooks(f(g(h())))`.
func (c *DeviceOfflineTimeClient) Use(hooks ...Hook) {
c.hooks.DeviceOfflineTime = append(c.hooks.DeviceOfflineTime, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `deviceofflinetime.Intercept(f(g(h())))`.
func (c *DeviceOfflineTimeClient) Intercept(interceptors ...Interceptor) {
c.inters.DeviceOfflineTime = append(c.inters.DeviceOfflineTime, interceptors...)
}
// Create returns a builder for creating a DeviceOfflineTime entity.
func (c *DeviceOfflineTimeClient) Create() *DeviceOfflineTimeCreate {
mutation := newDeviceOfflineTimeMutation(c.config, OpCreate)
return &DeviceOfflineTimeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of DeviceOfflineTime entities.
func (c *DeviceOfflineTimeClient) CreateBulk(builders ...*DeviceOfflineTimeCreate) *DeviceOfflineTimeCreateBulk {
return &DeviceOfflineTimeCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *DeviceOfflineTimeClient) MapCreateBulk(slice any, setFunc func(*DeviceOfflineTimeCreate, int)) *DeviceOfflineTimeCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &DeviceOfflineTimeCreateBulk{err: fmt.Errorf("calling to DeviceOfflineTimeClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*DeviceOfflineTimeCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &DeviceOfflineTimeCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for DeviceOfflineTime.
func (c *DeviceOfflineTimeClient) Update() *DeviceOfflineTimeUpdate {
mutation := newDeviceOfflineTimeMutation(c.config, OpUpdate)
return &DeviceOfflineTimeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *DeviceOfflineTimeClient) UpdateOne(dot *DeviceOfflineTime) *DeviceOfflineTimeUpdateOne {
mutation := newDeviceOfflineTimeMutation(c.config, OpUpdateOne, withDeviceOfflineTime(dot))
return &DeviceOfflineTimeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *DeviceOfflineTimeClient) UpdateOneID(id uint64) *DeviceOfflineTimeUpdateOne {
mutation := newDeviceOfflineTimeMutation(c.config, OpUpdateOne, withDeviceOfflineTimeID(id))
return &DeviceOfflineTimeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for DeviceOfflineTime.
func (c *DeviceOfflineTimeClient) Delete() *DeviceOfflineTimeDelete {
mutation := newDeviceOfflineTimeMutation(c.config, OpDelete)
return &DeviceOfflineTimeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *DeviceOfflineTimeClient) DeleteOne(dot *DeviceOfflineTime) *DeviceOfflineTimeDeleteOne {
return c.DeleteOneID(dot.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *DeviceOfflineTimeClient) DeleteOneID(id uint64) *DeviceOfflineTimeDeleteOne {
builder := c.Delete().Where(deviceofflinetime.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &DeviceOfflineTimeDeleteOne{builder}
}
// Query returns a query builder for DeviceOfflineTime.
func (c *DeviceOfflineTimeClient) Query() *DeviceOfflineTimeQuery {
return &DeviceOfflineTimeQuery{
config: c.config,
ctx: &QueryContext{Type: TypeDeviceOfflineTime},
inters: c.Interceptors(),
}
}
// Get returns a DeviceOfflineTime entity by its id.
func (c *DeviceOfflineTimeClient) Get(ctx context.Context, id uint64) (*DeviceOfflineTime, error) {
return c.Query().Where(deviceofflinetime.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *DeviceOfflineTimeClient) GetX(ctx context.Context, id uint64) *DeviceOfflineTime {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *DeviceOfflineTimeClient) Hooks() []Hook {
return c.hooks.DeviceOfflineTime
}
// Interceptors returns the client interceptors.
func (c *DeviceOfflineTimeClient) Interceptors() []Interceptor {
return c.inters.DeviceOfflineTime
}
func (c *DeviceOfflineTimeClient) mutate(ctx context.Context, m *DeviceOfflineTimeMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&DeviceOfflineTimeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&DeviceOfflineTimeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&DeviceOfflineTimeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&DeviceOfflineTimeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown DeviceOfflineTime mutation op: %q", m.Op())
}
}
// DeviceOnTimeDailyClient is a client for the DeviceOnTimeDaily schema.
type DeviceOnTimeDailyClient struct {
config
}
// NewDeviceOnTimeDailyClient returns a client for the DeviceOnTimeDaily from the given config.
func NewDeviceOnTimeDailyClient(c config) *DeviceOnTimeDailyClient {
return &DeviceOnTimeDailyClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `deviceontimedaily.Hooks(f(g(h())))`.
func (c *DeviceOnTimeDailyClient) Use(hooks ...Hook) {
c.hooks.DeviceOnTimeDaily = append(c.hooks.DeviceOnTimeDaily, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `deviceontimedaily.Intercept(f(g(h())))`.
func (c *DeviceOnTimeDailyClient) Intercept(interceptors ...Interceptor) {
c.inters.DeviceOnTimeDaily = append(c.inters.DeviceOnTimeDaily, interceptors...)
}
// Create returns a builder for creating a DeviceOnTimeDaily entity.
func (c *DeviceOnTimeDailyClient) Create() *DeviceOnTimeDailyCreate {
mutation := newDeviceOnTimeDailyMutation(c.config, OpCreate)
return &DeviceOnTimeDailyCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of DeviceOnTimeDaily entities.
func (c *DeviceOnTimeDailyClient) CreateBulk(builders ...*DeviceOnTimeDailyCreate) *DeviceOnTimeDailyCreateBulk {
return &DeviceOnTimeDailyCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *DeviceOnTimeDailyClient) MapCreateBulk(slice any, setFunc func(*DeviceOnTimeDailyCreate, int)) *DeviceOnTimeDailyCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &DeviceOnTimeDailyCreateBulk{err: fmt.Errorf("calling to DeviceOnTimeDailyClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*DeviceOnTimeDailyCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &DeviceOnTimeDailyCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for DeviceOnTimeDaily.
func (c *DeviceOnTimeDailyClient) Update() *DeviceOnTimeDailyUpdate {
mutation := newDeviceOnTimeDailyMutation(c.config, OpUpdate)
return &DeviceOnTimeDailyUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *DeviceOnTimeDailyClient) UpdateOne(dotd *DeviceOnTimeDaily) *DeviceOnTimeDailyUpdateOne {
mutation := newDeviceOnTimeDailyMutation(c.config, OpUpdateOne, withDeviceOnTimeDaily(dotd))
return &DeviceOnTimeDailyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *DeviceOnTimeDailyClient) UpdateOneID(id uint64) *DeviceOnTimeDailyUpdateOne {
mutation := newDeviceOnTimeDailyMutation(c.config, OpUpdateOne, withDeviceOnTimeDailyID(id))
return &DeviceOnTimeDailyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for DeviceOnTimeDaily.
func (c *DeviceOnTimeDailyClient) Delete() *DeviceOnTimeDailyDelete {
mutation := newDeviceOnTimeDailyMutation(c.config, OpDelete)
return &DeviceOnTimeDailyDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *DeviceOnTimeDailyClient) DeleteOne(dotd *DeviceOnTimeDaily) *DeviceOnTimeDailyDeleteOne {
return c.DeleteOneID(dotd.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *DeviceOnTimeDailyClient) DeleteOneID(id uint64) *DeviceOnTimeDailyDeleteOne {
builder := c.Delete().Where(deviceontimedaily.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &DeviceOnTimeDailyDeleteOne{builder}
}
// Query returns a query builder for DeviceOnTimeDaily.
func (c *DeviceOnTimeDailyClient) Query() *DeviceOnTimeDailyQuery {
return &DeviceOnTimeDailyQuery{
config: c.config,
ctx: &QueryContext{Type: TypeDeviceOnTimeDaily},
inters: c.Interceptors(),
}
}
// Get returns a DeviceOnTimeDaily entity by its id.
func (c *DeviceOnTimeDailyClient) Get(ctx context.Context, id uint64) (*DeviceOnTimeDaily, error) {
return c.Query().Where(deviceontimedaily.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *DeviceOnTimeDailyClient) GetX(ctx context.Context, id uint64) *DeviceOnTimeDaily {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *DeviceOnTimeDailyClient) Hooks() []Hook {
return c.hooks.DeviceOnTimeDaily
}
// Interceptors returns the client interceptors.
func (c *DeviceOnTimeDailyClient) Interceptors() []Interceptor {
return c.inters.DeviceOnTimeDaily
}
func (c *DeviceOnTimeDailyClient) mutate(ctx context.Context, m *DeviceOnTimeDailyMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&DeviceOnTimeDailyCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&DeviceOnTimeDailyUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&DeviceOnTimeDailyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&DeviceOnTimeDailyDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown DeviceOnTimeDaily mutation op: %q", m.Op())
}
}
// DeviceOnlineTimeClient is a client for the DeviceOnlineTime schema.
type DeviceOnlineTimeClient struct {
config
}
// NewDeviceOnlineTimeClient returns a client for the DeviceOnlineTime from the given config.
func NewDeviceOnlineTimeClient(c config) *DeviceOnlineTimeClient {
return &DeviceOnlineTimeClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `deviceonlinetime.Hooks(f(g(h())))`.
func (c *DeviceOnlineTimeClient) Use(hooks ...Hook) {
c.hooks.DeviceOnlineTime = append(c.hooks.DeviceOnlineTime, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `deviceonlinetime.Intercept(f(g(h())))`.
func (c *DeviceOnlineTimeClient) Intercept(interceptors ...Interceptor) {
c.inters.DeviceOnlineTime = append(c.inters.DeviceOnlineTime, interceptors...)
}
// Create returns a builder for creating a DeviceOnlineTime entity.
func (c *DeviceOnlineTimeClient) Create() *DeviceOnlineTimeCreate {
mutation := newDeviceOnlineTimeMutation(c.config, OpCreate)
return &DeviceOnlineTimeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of DeviceOnlineTime entities.
func (c *DeviceOnlineTimeClient) CreateBulk(builders ...*DeviceOnlineTimeCreate) *DeviceOnlineTimeCreateBulk {
return &DeviceOnlineTimeCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *DeviceOnlineTimeClient) MapCreateBulk(slice any, setFunc func(*DeviceOnlineTimeCreate, int)) *DeviceOnlineTimeCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &DeviceOnlineTimeCreateBulk{err: fmt.Errorf("calling to DeviceOnlineTimeClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*DeviceOnlineTimeCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &DeviceOnlineTimeCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for DeviceOnlineTime.
func (c *DeviceOnlineTimeClient) Update() *DeviceOnlineTimeUpdate {
mutation := newDeviceOnlineTimeMutation(c.config, OpUpdate)
return &DeviceOnlineTimeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *DeviceOnlineTimeClient) UpdateOne(dot *DeviceOnlineTime) *DeviceOnlineTimeUpdateOne {
mutation := newDeviceOnlineTimeMutation(c.config, OpUpdateOne, withDeviceOnlineTime(dot))
return &DeviceOnlineTimeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *DeviceOnlineTimeClient) UpdateOneID(id uint64) *DeviceOnlineTimeUpdateOne {
mutation := newDeviceOnlineTimeMutation(c.config, OpUpdateOne, withDeviceOnlineTimeID(id))
return &DeviceOnlineTimeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for DeviceOnlineTime.
func (c *DeviceOnlineTimeClient) Delete() *DeviceOnlineTimeDelete {
mutation := newDeviceOnlineTimeMutation(c.config, OpDelete)
return &DeviceOnlineTimeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *DeviceOnlineTimeClient) DeleteOne(dot *DeviceOnlineTime) *DeviceOnlineTimeDeleteOne {
return c.DeleteOneID(dot.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *DeviceOnlineTimeClient) DeleteOneID(id uint64) *DeviceOnlineTimeDeleteOne {
builder := c.Delete().Where(deviceonlinetime.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &DeviceOnlineTimeDeleteOne{builder}
}
// Query returns a query builder for DeviceOnlineTime.
func (c *DeviceOnlineTimeClient) Query() *DeviceOnlineTimeQuery {
return &DeviceOnlineTimeQuery{
config: c.config,
ctx: &QueryContext{Type: TypeDeviceOnlineTime},
inters: c.Interceptors(),
}
}
// Get returns a DeviceOnlineTime entity by its id.
func (c *DeviceOnlineTimeClient) Get(ctx context.Context, id uint64) (*DeviceOnlineTime, error) {
return c.Query().Where(deviceonlinetime.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *DeviceOnlineTimeClient) GetX(ctx context.Context, id uint64) *DeviceOnlineTime {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *DeviceOnlineTimeClient) Hooks() []Hook {
return c.hooks.DeviceOnlineTime
}
// Interceptors returns the client interceptors.
func (c *DeviceOnlineTimeClient) Interceptors() []Interceptor {
return c.inters.DeviceOnlineTime
}
func (c *DeviceOnlineTimeClient) mutate(ctx context.Context, m *DeviceOnlineTimeMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&DeviceOnlineTimeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&DeviceOnlineTimeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&DeviceOnlineTimeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&DeviceOnlineTimeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown DeviceOnlineTime mutation op: %q", m.Op())
}
}
// DeviceUpsterCycleClient is a client for the DeviceUpsterCycle schema.
type DeviceUpsterCycleClient struct {
config
}
// NewDeviceUpsterCycleClient returns a client for the DeviceUpsterCycle from the given config.
func NewDeviceUpsterCycleClient(c config) *DeviceUpsterCycleClient {
return &DeviceUpsterCycleClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `deviceupstercycle.Hooks(f(g(h())))`.
func (c *DeviceUpsterCycleClient) Use(hooks ...Hook) {
c.hooks.DeviceUpsterCycle = append(c.hooks.DeviceUpsterCycle, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `deviceupstercycle.Intercept(f(g(h())))`.
func (c *DeviceUpsterCycleClient) Intercept(interceptors ...Interceptor) {
c.inters.DeviceUpsterCycle = append(c.inters.DeviceUpsterCycle, interceptors...)
}
// Create returns a builder for creating a DeviceUpsterCycle entity.
func (c *DeviceUpsterCycleClient) Create() *DeviceUpsterCycleCreate {
mutation := newDeviceUpsterCycleMutation(c.config, OpCreate)
return &DeviceUpsterCycleCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of DeviceUpsterCycle entities.
func (c *DeviceUpsterCycleClient) CreateBulk(builders ...*DeviceUpsterCycleCreate) *DeviceUpsterCycleCreateBulk {
return &DeviceUpsterCycleCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *DeviceUpsterCycleClient) MapCreateBulk(slice any, setFunc func(*DeviceUpsterCycleCreate, int)) *DeviceUpsterCycleCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &DeviceUpsterCycleCreateBulk{err: fmt.Errorf("calling to DeviceUpsterCycleClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*DeviceUpsterCycleCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &DeviceUpsterCycleCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for DeviceUpsterCycle.
func (c *DeviceUpsterCycleClient) Update() *DeviceUpsterCycleUpdate {
mutation := newDeviceUpsterCycleMutation(c.config, OpUpdate)
return &DeviceUpsterCycleUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *DeviceUpsterCycleClient) UpdateOne(duc *DeviceUpsterCycle) *DeviceUpsterCycleUpdateOne {
mutation := newDeviceUpsterCycleMutation(c.config, OpUpdateOne, withDeviceUpsterCycle(duc))
return &DeviceUpsterCycleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *DeviceUpsterCycleClient) UpdateOneID(id uint64) *DeviceUpsterCycleUpdateOne {
mutation := newDeviceUpsterCycleMutation(c.config, OpUpdateOne, withDeviceUpsterCycleID(id))
return &DeviceUpsterCycleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for DeviceUpsterCycle.
func (c *DeviceUpsterCycleClient) Delete() *DeviceUpsterCycleDelete {
mutation := newDeviceUpsterCycleMutation(c.config, OpDelete)
return &DeviceUpsterCycleDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *DeviceUpsterCycleClient) DeleteOne(duc *DeviceUpsterCycle) *DeviceUpsterCycleDeleteOne {
return c.DeleteOneID(duc.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *DeviceUpsterCycleClient) DeleteOneID(id uint64) *DeviceUpsterCycleDeleteOne {
builder := c.Delete().Where(deviceupstercycle.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &DeviceUpsterCycleDeleteOne{builder}
}
// Query returns a query builder for DeviceUpsterCycle.
func (c *DeviceUpsterCycleClient) Query() *DeviceUpsterCycleQuery {
return &DeviceUpsterCycleQuery{
config: c.config,
ctx: &QueryContext{Type: TypeDeviceUpsterCycle},
inters: c.Interceptors(),
}
}
// Get returns a DeviceUpsterCycle entity by its id.
func (c *DeviceUpsterCycleClient) Get(ctx context.Context, id uint64) (*DeviceUpsterCycle, error) {
return c.Query().Where(deviceupstercycle.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *DeviceUpsterCycleClient) GetX(ctx context.Context, id uint64) *DeviceUpsterCycle {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *DeviceUpsterCycleClient) Hooks() []Hook {
return c.hooks.DeviceUpsterCycle
}
// Interceptors returns the client interceptors.
func (c *DeviceUpsterCycleClient) Interceptors() []Interceptor {
return c.inters.DeviceUpsterCycle
}
func (c *DeviceUpsterCycleClient) mutate(ctx context.Context, m *DeviceUpsterCycleMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&DeviceUpsterCycleCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&DeviceUpsterCycleUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&DeviceUpsterCycleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&DeviceUpsterCycleDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown DeviceUpsterCycle mutation op: %q", m.Op())
}
}
// DeviceUpsterStatisticsClient is a client for the DeviceUpsterStatistics schema.
type DeviceUpsterStatisticsClient struct {
config
}
// NewDeviceUpsterStatisticsClient returns a client for the DeviceUpsterStatistics from the given config.
func NewDeviceUpsterStatisticsClient(c config) *DeviceUpsterStatisticsClient {
return &DeviceUpsterStatisticsClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `deviceupsterstatistics.Hooks(f(g(h())))`.
func (c *DeviceUpsterStatisticsClient) Use(hooks ...Hook) {
c.hooks.DeviceUpsterStatistics = append(c.hooks.DeviceUpsterStatistics, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `deviceupsterstatistics.Intercept(f(g(h())))`.
func (c *DeviceUpsterStatisticsClient) Intercept(interceptors ...Interceptor) {
c.inters.DeviceUpsterStatistics = append(c.inters.DeviceUpsterStatistics, interceptors...)
}
// Create returns a builder for creating a DeviceUpsterStatistics entity.
func (c *DeviceUpsterStatisticsClient) Create() *DeviceUpsterStatisticsCreate {
mutation := newDeviceUpsterStatisticsMutation(c.config, OpCreate)
return &DeviceUpsterStatisticsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of DeviceUpsterStatistics entities.
func (c *DeviceUpsterStatisticsClient) CreateBulk(builders ...*DeviceUpsterStatisticsCreate) *DeviceUpsterStatisticsCreateBulk {
return &DeviceUpsterStatisticsCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *DeviceUpsterStatisticsClient) MapCreateBulk(slice any, setFunc func(*DeviceUpsterStatisticsCreate, int)) *DeviceUpsterStatisticsCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &DeviceUpsterStatisticsCreateBulk{err: fmt.Errorf("calling to DeviceUpsterStatisticsClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*DeviceUpsterStatisticsCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &DeviceUpsterStatisticsCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for DeviceUpsterStatistics.
func (c *DeviceUpsterStatisticsClient) Update() *DeviceUpsterStatisticsUpdate {
mutation := newDeviceUpsterStatisticsMutation(c.config, OpUpdate)
return &DeviceUpsterStatisticsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *DeviceUpsterStatisticsClient) UpdateOne(dus *DeviceUpsterStatistics) *DeviceUpsterStatisticsUpdateOne {
mutation := newDeviceUpsterStatisticsMutation(c.config, OpUpdateOne, withDeviceUpsterStatistics(dus))
return &DeviceUpsterStatisticsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *DeviceUpsterStatisticsClient) UpdateOneID(id uint64) *DeviceUpsterStatisticsUpdateOne {
mutation := newDeviceUpsterStatisticsMutation(c.config, OpUpdateOne, withDeviceUpsterStatisticsID(id))
return &DeviceUpsterStatisticsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for DeviceUpsterStatistics.
func (c *DeviceUpsterStatisticsClient) Delete() *DeviceUpsterStatisticsDelete {
mutation := newDeviceUpsterStatisticsMutation(c.config, OpDelete)
return &DeviceUpsterStatisticsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *DeviceUpsterStatisticsClient) DeleteOne(dus *DeviceUpsterStatistics) *DeviceUpsterStatisticsDeleteOne {
return c.DeleteOneID(dus.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *DeviceUpsterStatisticsClient) DeleteOneID(id uint64) *DeviceUpsterStatisticsDeleteOne {
builder := c.Delete().Where(deviceupsterstatistics.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &DeviceUpsterStatisticsDeleteOne{builder}
}
// Query returns a query builder for DeviceUpsterStatistics.
func (c *DeviceUpsterStatisticsClient) Query() *DeviceUpsterStatisticsQuery {
return &DeviceUpsterStatisticsQuery{
config: c.config,
ctx: &QueryContext{Type: TypeDeviceUpsterStatistics},
inters: c.Interceptors(),
}
}
// Get returns a DeviceUpsterStatistics entity by its id.
func (c *DeviceUpsterStatisticsClient) Get(ctx context.Context, id uint64) (*DeviceUpsterStatistics, error) {
return c.Query().Where(deviceupsterstatistics.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *DeviceUpsterStatisticsClient) GetX(ctx context.Context, id uint64) *DeviceUpsterStatistics {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *DeviceUpsterStatisticsClient) Hooks() []Hook {
return c.hooks.DeviceUpsterStatistics
}
// Interceptors returns the client interceptors.
func (c *DeviceUpsterStatisticsClient) Interceptors() []Interceptor {
return c.inters.DeviceUpsterStatistics
}
func (c *DeviceUpsterStatisticsClient) mutate(ctx context.Context, m *DeviceUpsterStatisticsMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&DeviceUpsterStatisticsCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&DeviceUpsterStatisticsUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&DeviceUpsterStatisticsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&DeviceUpsterStatisticsDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown DeviceUpsterStatistics mutation op: %q", m.Op())
}
}
// hooks and interceptors per client, for fast access.
type (
hooks struct {
DeviceDuration, DeviceDurationElephant, DeviceEvent, DeviceKpi,
DeviceOfflineTime, DeviceOnTimeDaily, DeviceOnlineTime, DeviceUpsterCycle,
DeviceUpsterStatistics []ent.Hook
}
inters struct {
DeviceDuration, DeviceDurationElephant, DeviceEvent, DeviceKpi,
DeviceOfflineTime, DeviceOnTimeDaily, DeviceOnlineTime, DeviceUpsterCycle,
DeviceUpsterStatistics []ent.Interceptor
}
)
// ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it.
// See, database/sql#DB.ExecContext for more information.
func (c *config) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error) {
ex, ok := c.driver.(interface {
ExecContext(context.Context, string, ...any) (stdsql.Result, error)
})
if !ok {
return nil, fmt.Errorf("Driver.ExecContext is not supported")
}
return ex.ExecContext(ctx, query, args...)
}
// QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it.
// See, database/sql#DB.QueryContext for more information.
func (c *config) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error) {
q, ok := c.driver.(interface {
QueryContext(context.Context, string, ...any) (*stdsql.Rows, error)
})
if !ok {
return nil, fmt.Errorf("Driver.QueryContext is not supported")
}
return q.QueryContext(ctx, query, args...)
}
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