mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2026-01-01 02:27:32 +01:00
2800 lines
102 KiB
Go
Generated
2800 lines
102 KiB
Go
Generated
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"log"
|
|
"reflect"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/migrate"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect"
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/authroles"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/authtokens"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
|
|
)
|
|
|
|
// 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
|
|
// Attachment is the client for interacting with the Attachment builders.
|
|
Attachment *AttachmentClient
|
|
// AuthRoles is the client for interacting with the AuthRoles builders.
|
|
AuthRoles *AuthRolesClient
|
|
// AuthTokens is the client for interacting with the AuthTokens builders.
|
|
AuthTokens *AuthTokensClient
|
|
// Entity is the client for interacting with the Entity builders.
|
|
Entity *EntityClient
|
|
// EntityField is the client for interacting with the EntityField builders.
|
|
EntityField *EntityFieldClient
|
|
// EntityType is the client for interacting with the EntityType builders.
|
|
EntityType *EntityTypeClient
|
|
// Group is the client for interacting with the Group builders.
|
|
Group *GroupClient
|
|
// GroupInvitationToken is the client for interacting with the GroupInvitationToken builders.
|
|
GroupInvitationToken *GroupInvitationTokenClient
|
|
// ItemTemplate is the client for interacting with the ItemTemplate builders.
|
|
ItemTemplate *ItemTemplateClient
|
|
// Label is the client for interacting with the Label builders.
|
|
Label *LabelClient
|
|
// MaintenanceEntry is the client for interacting with the MaintenanceEntry builders.
|
|
MaintenanceEntry *MaintenanceEntryClient
|
|
// Notifier is the client for interacting with the Notifier builders.
|
|
Notifier *NotifierClient
|
|
// TemplateField is the client for interacting with the TemplateField builders.
|
|
TemplateField *TemplateFieldClient
|
|
// User is the client for interacting with the User builders.
|
|
User *UserClient
|
|
}
|
|
|
|
// 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.Attachment = NewAttachmentClient(c.config)
|
|
c.AuthRoles = NewAuthRolesClient(c.config)
|
|
c.AuthTokens = NewAuthTokensClient(c.config)
|
|
c.Entity = NewEntityClient(c.config)
|
|
c.EntityField = NewEntityFieldClient(c.config)
|
|
c.EntityType = NewEntityTypeClient(c.config)
|
|
c.Group = NewGroupClient(c.config)
|
|
c.GroupInvitationToken = NewGroupInvitationTokenClient(c.config)
|
|
c.ItemTemplate = NewItemTemplateClient(c.config)
|
|
c.Label = NewLabelClient(c.config)
|
|
c.MaintenanceEntry = NewMaintenanceEntryClient(c.config)
|
|
c.Notifier = NewNotifierClient(c.config)
|
|
c.TemplateField = NewTemplateFieldClient(c.config)
|
|
c.User = NewUserClient(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,
|
|
Attachment: NewAttachmentClient(cfg),
|
|
AuthRoles: NewAuthRolesClient(cfg),
|
|
AuthTokens: NewAuthTokensClient(cfg),
|
|
Entity: NewEntityClient(cfg),
|
|
EntityField: NewEntityFieldClient(cfg),
|
|
EntityType: NewEntityTypeClient(cfg),
|
|
Group: NewGroupClient(cfg),
|
|
GroupInvitationToken: NewGroupInvitationTokenClient(cfg),
|
|
ItemTemplate: NewItemTemplateClient(cfg),
|
|
Label: NewLabelClient(cfg),
|
|
MaintenanceEntry: NewMaintenanceEntryClient(cfg),
|
|
Notifier: NewNotifierClient(cfg),
|
|
TemplateField: NewTemplateFieldClient(cfg),
|
|
User: NewUserClient(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,
|
|
Attachment: NewAttachmentClient(cfg),
|
|
AuthRoles: NewAuthRolesClient(cfg),
|
|
AuthTokens: NewAuthTokensClient(cfg),
|
|
Entity: NewEntityClient(cfg),
|
|
EntityField: NewEntityFieldClient(cfg),
|
|
EntityType: NewEntityTypeClient(cfg),
|
|
Group: NewGroupClient(cfg),
|
|
GroupInvitationToken: NewGroupInvitationTokenClient(cfg),
|
|
ItemTemplate: NewItemTemplateClient(cfg),
|
|
Label: NewLabelClient(cfg),
|
|
MaintenanceEntry: NewMaintenanceEntryClient(cfg),
|
|
Notifier: NewNotifierClient(cfg),
|
|
TemplateField: NewTemplateFieldClient(cfg),
|
|
User: NewUserClient(cfg),
|
|
}, nil
|
|
}
|
|
|
|
// Debug returns a new debug-client. It's used to get verbose logging on specific operations.
|
|
//
|
|
// client.Debug().
|
|
// Attachment.
|
|
// 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.Attachment, c.AuthRoles, c.AuthTokens, c.Entity, c.EntityField, c.EntityType,
|
|
c.Group, c.GroupInvitationToken, c.ItemTemplate, c.Label, c.MaintenanceEntry,
|
|
c.Notifier, c.TemplateField, c.User,
|
|
} {
|
|
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.Attachment, c.AuthRoles, c.AuthTokens, c.Entity, c.EntityField, c.EntityType,
|
|
c.Group, c.GroupInvitationToken, c.ItemTemplate, c.Label, c.MaintenanceEntry,
|
|
c.Notifier, c.TemplateField, c.User,
|
|
} {
|
|
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 *AttachmentMutation:
|
|
return c.Attachment.mutate(ctx, m)
|
|
case *AuthRolesMutation:
|
|
return c.AuthRoles.mutate(ctx, m)
|
|
case *AuthTokensMutation:
|
|
return c.AuthTokens.mutate(ctx, m)
|
|
case *EntityMutation:
|
|
return c.Entity.mutate(ctx, m)
|
|
case *EntityFieldMutation:
|
|
return c.EntityField.mutate(ctx, m)
|
|
case *EntityTypeMutation:
|
|
return c.EntityType.mutate(ctx, m)
|
|
case *GroupMutation:
|
|
return c.Group.mutate(ctx, m)
|
|
case *GroupInvitationTokenMutation:
|
|
return c.GroupInvitationToken.mutate(ctx, m)
|
|
case *ItemTemplateMutation:
|
|
return c.ItemTemplate.mutate(ctx, m)
|
|
case *LabelMutation:
|
|
return c.Label.mutate(ctx, m)
|
|
case *MaintenanceEntryMutation:
|
|
return c.MaintenanceEntry.mutate(ctx, m)
|
|
case *NotifierMutation:
|
|
return c.Notifier.mutate(ctx, m)
|
|
case *TemplateFieldMutation:
|
|
return c.TemplateField.mutate(ctx, m)
|
|
case *UserMutation:
|
|
return c.User.mutate(ctx, m)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown mutation type %T", m)
|
|
}
|
|
}
|
|
|
|
// AttachmentClient is a client for the Attachment schema.
|
|
type AttachmentClient struct {
|
|
config
|
|
}
|
|
|
|
// NewAttachmentClient returns a client for the Attachment from the given config.
|
|
func NewAttachmentClient(c config) *AttachmentClient {
|
|
return &AttachmentClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `attachment.Hooks(f(g(h())))`.
|
|
func (c *AttachmentClient) Use(hooks ...Hook) {
|
|
c.hooks.Attachment = append(c.hooks.Attachment, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `attachment.Intercept(f(g(h())))`.
|
|
func (c *AttachmentClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.Attachment = append(c.inters.Attachment, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a Attachment entity.
|
|
func (c *AttachmentClient) Create() *AttachmentCreate {
|
|
mutation := newAttachmentMutation(c.config, OpCreate)
|
|
return &AttachmentCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of Attachment entities.
|
|
func (c *AttachmentClient) CreateBulk(builders ...*AttachmentCreate) *AttachmentCreateBulk {
|
|
return &AttachmentCreateBulk{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 *AttachmentClient) MapCreateBulk(slice any, setFunc func(*AttachmentCreate, int)) *AttachmentCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &AttachmentCreateBulk{err: fmt.Errorf("calling to AttachmentClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*AttachmentCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &AttachmentCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for Attachment.
|
|
func (c *AttachmentClient) Update() *AttachmentUpdate {
|
|
mutation := newAttachmentMutation(c.config, OpUpdate)
|
|
return &AttachmentUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *AttachmentClient) UpdateOne(_m *Attachment) *AttachmentUpdateOne {
|
|
mutation := newAttachmentMutation(c.config, OpUpdateOne, withAttachment(_m))
|
|
return &AttachmentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *AttachmentClient) UpdateOneID(id uuid.UUID) *AttachmentUpdateOne {
|
|
mutation := newAttachmentMutation(c.config, OpUpdateOne, withAttachmentID(id))
|
|
return &AttachmentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for Attachment.
|
|
func (c *AttachmentClient) Delete() *AttachmentDelete {
|
|
mutation := newAttachmentMutation(c.config, OpDelete)
|
|
return &AttachmentDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *AttachmentClient) DeleteOne(_m *Attachment) *AttachmentDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *AttachmentClient) DeleteOneID(id uuid.UUID) *AttachmentDeleteOne {
|
|
builder := c.Delete().Where(attachment.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &AttachmentDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for Attachment.
|
|
func (c *AttachmentClient) Query() *AttachmentQuery {
|
|
return &AttachmentQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeAttachment},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a Attachment entity by its id.
|
|
func (c *AttachmentClient) Get(ctx context.Context, id uuid.UUID) (*Attachment, error) {
|
|
return c.Query().Where(attachment.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *AttachmentClient) GetX(ctx context.Context, id uuid.UUID) *Attachment {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryEntity queries the entity edge of a Attachment.
|
|
func (c *AttachmentClient) QueryEntity(_m *Attachment) *EntityQuery {
|
|
query := (&EntityClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(attachment.Table, attachment.FieldID, id),
|
|
sqlgraph.To(entity.Table, entity.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, attachment.EntityTable, attachment.EntityColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryThumbnail queries the thumbnail edge of a Attachment.
|
|
func (c *AttachmentClient) QueryThumbnail(_m *Attachment) *AttachmentQuery {
|
|
query := (&AttachmentClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(attachment.Table, attachment.FieldID, id),
|
|
sqlgraph.To(attachment.Table, attachment.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2O, false, attachment.ThumbnailTable, attachment.ThumbnailColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *AttachmentClient) Hooks() []Hook {
|
|
return c.hooks.Attachment
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *AttachmentClient) Interceptors() []Interceptor {
|
|
return c.inters.Attachment
|
|
}
|
|
|
|
func (c *AttachmentClient) mutate(ctx context.Context, m *AttachmentMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&AttachmentCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&AttachmentUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&AttachmentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&AttachmentDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown Attachment mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// AuthRolesClient is a client for the AuthRoles schema.
|
|
type AuthRolesClient struct {
|
|
config
|
|
}
|
|
|
|
// NewAuthRolesClient returns a client for the AuthRoles from the given config.
|
|
func NewAuthRolesClient(c config) *AuthRolesClient {
|
|
return &AuthRolesClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `authroles.Hooks(f(g(h())))`.
|
|
func (c *AuthRolesClient) Use(hooks ...Hook) {
|
|
c.hooks.AuthRoles = append(c.hooks.AuthRoles, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `authroles.Intercept(f(g(h())))`.
|
|
func (c *AuthRolesClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.AuthRoles = append(c.inters.AuthRoles, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a AuthRoles entity.
|
|
func (c *AuthRolesClient) Create() *AuthRolesCreate {
|
|
mutation := newAuthRolesMutation(c.config, OpCreate)
|
|
return &AuthRolesCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of AuthRoles entities.
|
|
func (c *AuthRolesClient) CreateBulk(builders ...*AuthRolesCreate) *AuthRolesCreateBulk {
|
|
return &AuthRolesCreateBulk{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 *AuthRolesClient) MapCreateBulk(slice any, setFunc func(*AuthRolesCreate, int)) *AuthRolesCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &AuthRolesCreateBulk{err: fmt.Errorf("calling to AuthRolesClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*AuthRolesCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &AuthRolesCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for AuthRoles.
|
|
func (c *AuthRolesClient) Update() *AuthRolesUpdate {
|
|
mutation := newAuthRolesMutation(c.config, OpUpdate)
|
|
return &AuthRolesUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *AuthRolesClient) UpdateOne(_m *AuthRoles) *AuthRolesUpdateOne {
|
|
mutation := newAuthRolesMutation(c.config, OpUpdateOne, withAuthRoles(_m))
|
|
return &AuthRolesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *AuthRolesClient) UpdateOneID(id int) *AuthRolesUpdateOne {
|
|
mutation := newAuthRolesMutation(c.config, OpUpdateOne, withAuthRolesID(id))
|
|
return &AuthRolesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for AuthRoles.
|
|
func (c *AuthRolesClient) Delete() *AuthRolesDelete {
|
|
mutation := newAuthRolesMutation(c.config, OpDelete)
|
|
return &AuthRolesDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *AuthRolesClient) DeleteOne(_m *AuthRoles) *AuthRolesDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *AuthRolesClient) DeleteOneID(id int) *AuthRolesDeleteOne {
|
|
builder := c.Delete().Where(authroles.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &AuthRolesDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for AuthRoles.
|
|
func (c *AuthRolesClient) Query() *AuthRolesQuery {
|
|
return &AuthRolesQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeAuthRoles},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a AuthRoles entity by its id.
|
|
func (c *AuthRolesClient) Get(ctx context.Context, id int) (*AuthRoles, error) {
|
|
return c.Query().Where(authroles.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *AuthRolesClient) GetX(ctx context.Context, id int) *AuthRoles {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryToken queries the token edge of a AuthRoles.
|
|
func (c *AuthRolesClient) QueryToken(_m *AuthRoles) *AuthTokensQuery {
|
|
query := (&AuthTokensClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(authroles.Table, authroles.FieldID, id),
|
|
sqlgraph.To(authtokens.Table, authtokens.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2O, true, authroles.TokenTable, authroles.TokenColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *AuthRolesClient) Hooks() []Hook {
|
|
return c.hooks.AuthRoles
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *AuthRolesClient) Interceptors() []Interceptor {
|
|
return c.inters.AuthRoles
|
|
}
|
|
|
|
func (c *AuthRolesClient) mutate(ctx context.Context, m *AuthRolesMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&AuthRolesCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&AuthRolesUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&AuthRolesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&AuthRolesDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown AuthRoles mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// AuthTokensClient is a client for the AuthTokens schema.
|
|
type AuthTokensClient struct {
|
|
config
|
|
}
|
|
|
|
// NewAuthTokensClient returns a client for the AuthTokens from the given config.
|
|
func NewAuthTokensClient(c config) *AuthTokensClient {
|
|
return &AuthTokensClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `authtokens.Hooks(f(g(h())))`.
|
|
func (c *AuthTokensClient) Use(hooks ...Hook) {
|
|
c.hooks.AuthTokens = append(c.hooks.AuthTokens, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `authtokens.Intercept(f(g(h())))`.
|
|
func (c *AuthTokensClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.AuthTokens = append(c.inters.AuthTokens, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a AuthTokens entity.
|
|
func (c *AuthTokensClient) Create() *AuthTokensCreate {
|
|
mutation := newAuthTokensMutation(c.config, OpCreate)
|
|
return &AuthTokensCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of AuthTokens entities.
|
|
func (c *AuthTokensClient) CreateBulk(builders ...*AuthTokensCreate) *AuthTokensCreateBulk {
|
|
return &AuthTokensCreateBulk{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 *AuthTokensClient) MapCreateBulk(slice any, setFunc func(*AuthTokensCreate, int)) *AuthTokensCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &AuthTokensCreateBulk{err: fmt.Errorf("calling to AuthTokensClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*AuthTokensCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &AuthTokensCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for AuthTokens.
|
|
func (c *AuthTokensClient) Update() *AuthTokensUpdate {
|
|
mutation := newAuthTokensMutation(c.config, OpUpdate)
|
|
return &AuthTokensUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *AuthTokensClient) UpdateOne(_m *AuthTokens) *AuthTokensUpdateOne {
|
|
mutation := newAuthTokensMutation(c.config, OpUpdateOne, withAuthTokens(_m))
|
|
return &AuthTokensUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *AuthTokensClient) UpdateOneID(id uuid.UUID) *AuthTokensUpdateOne {
|
|
mutation := newAuthTokensMutation(c.config, OpUpdateOne, withAuthTokensID(id))
|
|
return &AuthTokensUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for AuthTokens.
|
|
func (c *AuthTokensClient) Delete() *AuthTokensDelete {
|
|
mutation := newAuthTokensMutation(c.config, OpDelete)
|
|
return &AuthTokensDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *AuthTokensClient) DeleteOne(_m *AuthTokens) *AuthTokensDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *AuthTokensClient) DeleteOneID(id uuid.UUID) *AuthTokensDeleteOne {
|
|
builder := c.Delete().Where(authtokens.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &AuthTokensDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for AuthTokens.
|
|
func (c *AuthTokensClient) Query() *AuthTokensQuery {
|
|
return &AuthTokensQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeAuthTokens},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a AuthTokens entity by its id.
|
|
func (c *AuthTokensClient) Get(ctx context.Context, id uuid.UUID) (*AuthTokens, error) {
|
|
return c.Query().Where(authtokens.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *AuthTokensClient) GetX(ctx context.Context, id uuid.UUID) *AuthTokens {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryUser queries the user edge of a AuthTokens.
|
|
func (c *AuthTokensClient) QueryUser(_m *AuthTokens) *UserQuery {
|
|
query := (&UserClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(authtokens.Table, authtokens.FieldID, id),
|
|
sqlgraph.To(user.Table, user.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, authtokens.UserTable, authtokens.UserColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryRoles queries the roles edge of a AuthTokens.
|
|
func (c *AuthTokensClient) QueryRoles(_m *AuthTokens) *AuthRolesQuery {
|
|
query := (&AuthRolesClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(authtokens.Table, authtokens.FieldID, id),
|
|
sqlgraph.To(authroles.Table, authroles.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2O, false, authtokens.RolesTable, authtokens.RolesColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *AuthTokensClient) Hooks() []Hook {
|
|
return c.hooks.AuthTokens
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *AuthTokensClient) Interceptors() []Interceptor {
|
|
return c.inters.AuthTokens
|
|
}
|
|
|
|
func (c *AuthTokensClient) mutate(ctx context.Context, m *AuthTokensMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&AuthTokensCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&AuthTokensUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&AuthTokensUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&AuthTokensDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown AuthTokens mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// EntityClient is a client for the Entity schema.
|
|
type EntityClient struct {
|
|
config
|
|
}
|
|
|
|
// NewEntityClient returns a client for the Entity from the given config.
|
|
func NewEntityClient(c config) *EntityClient {
|
|
return &EntityClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `entity.Hooks(f(g(h())))`.
|
|
func (c *EntityClient) Use(hooks ...Hook) {
|
|
c.hooks.Entity = append(c.hooks.Entity, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `entity.Intercept(f(g(h())))`.
|
|
func (c *EntityClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.Entity = append(c.inters.Entity, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a Entity entity.
|
|
func (c *EntityClient) Create() *EntityCreate {
|
|
mutation := newEntityMutation(c.config, OpCreate)
|
|
return &EntityCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of Entity entities.
|
|
func (c *EntityClient) CreateBulk(builders ...*EntityCreate) *EntityCreateBulk {
|
|
return &EntityCreateBulk{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 *EntityClient) MapCreateBulk(slice any, setFunc func(*EntityCreate, int)) *EntityCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &EntityCreateBulk{err: fmt.Errorf("calling to EntityClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*EntityCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &EntityCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for Entity.
|
|
func (c *EntityClient) Update() *EntityUpdate {
|
|
mutation := newEntityMutation(c.config, OpUpdate)
|
|
return &EntityUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *EntityClient) UpdateOne(_m *Entity) *EntityUpdateOne {
|
|
mutation := newEntityMutation(c.config, OpUpdateOne, withEntity(_m))
|
|
return &EntityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *EntityClient) UpdateOneID(id uuid.UUID) *EntityUpdateOne {
|
|
mutation := newEntityMutation(c.config, OpUpdateOne, withEntityID(id))
|
|
return &EntityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for Entity.
|
|
func (c *EntityClient) Delete() *EntityDelete {
|
|
mutation := newEntityMutation(c.config, OpDelete)
|
|
return &EntityDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *EntityClient) DeleteOne(_m *Entity) *EntityDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *EntityClient) DeleteOneID(id uuid.UUID) *EntityDeleteOne {
|
|
builder := c.Delete().Where(entity.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &EntityDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for Entity.
|
|
func (c *EntityClient) Query() *EntityQuery {
|
|
return &EntityQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeEntity},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a Entity entity by its id.
|
|
func (c *EntityClient) Get(ctx context.Context, id uuid.UUID) (*Entity, error) {
|
|
return c.Query().Where(entity.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *EntityClient) GetX(ctx context.Context, id uuid.UUID) *Entity {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryGroup queries the group edge of a Entity.
|
|
func (c *EntityClient) QueryGroup(_m *Entity) *GroupQuery {
|
|
query := (&GroupClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(entity.Table, entity.FieldID, id),
|
|
sqlgraph.To(group.Table, group.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, entity.GroupTable, entity.GroupColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryChildren queries the children edge of a Entity.
|
|
func (c *EntityClient) QueryChildren(_m *Entity) *EntityQuery {
|
|
query := (&EntityClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(entity.Table, entity.FieldID, id),
|
|
sqlgraph.To(entity.Table, entity.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, true, entity.ChildrenTable, entity.ChildrenColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryParent queries the parent edge of a Entity.
|
|
func (c *EntityClient) QueryParent(_m *Entity) *EntityQuery {
|
|
query := (&EntityClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(entity.Table, entity.FieldID, id),
|
|
sqlgraph.To(entity.Table, entity.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, false, entity.ParentTable, entity.ParentColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryEntity queries the entity edge of a Entity.
|
|
func (c *EntityClient) QueryEntity(_m *Entity) *EntityQuery {
|
|
query := (&EntityClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(entity.Table, entity.FieldID, id),
|
|
sqlgraph.To(entity.Table, entity.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, true, entity.EntityTable, entity.EntityColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryLocation queries the location edge of a Entity.
|
|
func (c *EntityClient) QueryLocation(_m *Entity) *EntityQuery {
|
|
query := (&EntityClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(entity.Table, entity.FieldID, id),
|
|
sqlgraph.To(entity.Table, entity.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, false, entity.LocationTable, entity.LocationColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryLabel queries the label edge of a Entity.
|
|
func (c *EntityClient) QueryLabel(_m *Entity) *LabelQuery {
|
|
query := (&LabelClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(entity.Table, entity.FieldID, id),
|
|
sqlgraph.To(label.Table, label.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2M, true, entity.LabelTable, entity.LabelPrimaryKey...),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryType queries the type edge of a Entity.
|
|
func (c *EntityClient) QueryType(_m *Entity) *EntityTypeQuery {
|
|
query := (&EntityTypeClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(entity.Table, entity.FieldID, id),
|
|
sqlgraph.To(entitytype.Table, entitytype.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, entity.TypeTable, entity.TypeColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryFields queries the fields edge of a Entity.
|
|
func (c *EntityClient) QueryFields(_m *Entity) *EntityFieldQuery {
|
|
query := (&EntityFieldClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(entity.Table, entity.FieldID, id),
|
|
sqlgraph.To(entityfield.Table, entityfield.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, entity.FieldsTable, entity.FieldsColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryMaintenanceEntries queries the maintenance_entries edge of a Entity.
|
|
func (c *EntityClient) QueryMaintenanceEntries(_m *Entity) *MaintenanceEntryQuery {
|
|
query := (&MaintenanceEntryClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(entity.Table, entity.FieldID, id),
|
|
sqlgraph.To(maintenanceentry.Table, maintenanceentry.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, entity.MaintenanceEntriesTable, entity.MaintenanceEntriesColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryAttachments queries the attachments edge of a Entity.
|
|
func (c *EntityClient) QueryAttachments(_m *Entity) *AttachmentQuery {
|
|
query := (&AttachmentClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(entity.Table, entity.FieldID, id),
|
|
sqlgraph.To(attachment.Table, attachment.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, entity.AttachmentsTable, entity.AttachmentsColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *EntityClient) Hooks() []Hook {
|
|
return c.hooks.Entity
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *EntityClient) Interceptors() []Interceptor {
|
|
return c.inters.Entity
|
|
}
|
|
|
|
func (c *EntityClient) mutate(ctx context.Context, m *EntityMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&EntityCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&EntityUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&EntityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&EntityDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown Entity mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// EntityFieldClient is a client for the EntityField schema.
|
|
type EntityFieldClient struct {
|
|
config
|
|
}
|
|
|
|
// NewEntityFieldClient returns a client for the EntityField from the given config.
|
|
func NewEntityFieldClient(c config) *EntityFieldClient {
|
|
return &EntityFieldClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `entityfield.Hooks(f(g(h())))`.
|
|
func (c *EntityFieldClient) Use(hooks ...Hook) {
|
|
c.hooks.EntityField = append(c.hooks.EntityField, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `entityfield.Intercept(f(g(h())))`.
|
|
func (c *EntityFieldClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.EntityField = append(c.inters.EntityField, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a EntityField entity.
|
|
func (c *EntityFieldClient) Create() *EntityFieldCreate {
|
|
mutation := newEntityFieldMutation(c.config, OpCreate)
|
|
return &EntityFieldCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of EntityField entities.
|
|
func (c *EntityFieldClient) CreateBulk(builders ...*EntityFieldCreate) *EntityFieldCreateBulk {
|
|
return &EntityFieldCreateBulk{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 *EntityFieldClient) MapCreateBulk(slice any, setFunc func(*EntityFieldCreate, int)) *EntityFieldCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &EntityFieldCreateBulk{err: fmt.Errorf("calling to EntityFieldClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*EntityFieldCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &EntityFieldCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for EntityField.
|
|
func (c *EntityFieldClient) Update() *EntityFieldUpdate {
|
|
mutation := newEntityFieldMutation(c.config, OpUpdate)
|
|
return &EntityFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *EntityFieldClient) UpdateOne(_m *EntityField) *EntityFieldUpdateOne {
|
|
mutation := newEntityFieldMutation(c.config, OpUpdateOne, withEntityField(_m))
|
|
return &EntityFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *EntityFieldClient) UpdateOneID(id uuid.UUID) *EntityFieldUpdateOne {
|
|
mutation := newEntityFieldMutation(c.config, OpUpdateOne, withEntityFieldID(id))
|
|
return &EntityFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for EntityField.
|
|
func (c *EntityFieldClient) Delete() *EntityFieldDelete {
|
|
mutation := newEntityFieldMutation(c.config, OpDelete)
|
|
return &EntityFieldDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *EntityFieldClient) DeleteOne(_m *EntityField) *EntityFieldDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *EntityFieldClient) DeleteOneID(id uuid.UUID) *EntityFieldDeleteOne {
|
|
builder := c.Delete().Where(entityfield.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &EntityFieldDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for EntityField.
|
|
func (c *EntityFieldClient) Query() *EntityFieldQuery {
|
|
return &EntityFieldQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeEntityField},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a EntityField entity by its id.
|
|
func (c *EntityFieldClient) Get(ctx context.Context, id uuid.UUID) (*EntityField, error) {
|
|
return c.Query().Where(entityfield.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *EntityFieldClient) GetX(ctx context.Context, id uuid.UUID) *EntityField {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryEntity queries the entity edge of a EntityField.
|
|
func (c *EntityFieldClient) QueryEntity(_m *EntityField) *EntityQuery {
|
|
query := (&EntityClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(entityfield.Table, entityfield.FieldID, id),
|
|
sqlgraph.To(entity.Table, entity.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, entityfield.EntityTable, entityfield.EntityColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *EntityFieldClient) Hooks() []Hook {
|
|
return c.hooks.EntityField
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *EntityFieldClient) Interceptors() []Interceptor {
|
|
return c.inters.EntityField
|
|
}
|
|
|
|
func (c *EntityFieldClient) mutate(ctx context.Context, m *EntityFieldMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&EntityFieldCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&EntityFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&EntityFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&EntityFieldDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown EntityField mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// EntityTypeClient is a client for the EntityType schema.
|
|
type EntityTypeClient struct {
|
|
config
|
|
}
|
|
|
|
// NewEntityTypeClient returns a client for the EntityType from the given config.
|
|
func NewEntityTypeClient(c config) *EntityTypeClient {
|
|
return &EntityTypeClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `entitytype.Hooks(f(g(h())))`.
|
|
func (c *EntityTypeClient) Use(hooks ...Hook) {
|
|
c.hooks.EntityType = append(c.hooks.EntityType, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `entitytype.Intercept(f(g(h())))`.
|
|
func (c *EntityTypeClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.EntityType = append(c.inters.EntityType, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a EntityType entity.
|
|
func (c *EntityTypeClient) Create() *EntityTypeCreate {
|
|
mutation := newEntityTypeMutation(c.config, OpCreate)
|
|
return &EntityTypeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of EntityType entities.
|
|
func (c *EntityTypeClient) CreateBulk(builders ...*EntityTypeCreate) *EntityTypeCreateBulk {
|
|
return &EntityTypeCreateBulk{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 *EntityTypeClient) MapCreateBulk(slice any, setFunc func(*EntityTypeCreate, int)) *EntityTypeCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &EntityTypeCreateBulk{err: fmt.Errorf("calling to EntityTypeClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*EntityTypeCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &EntityTypeCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for EntityType.
|
|
func (c *EntityTypeClient) Update() *EntityTypeUpdate {
|
|
mutation := newEntityTypeMutation(c.config, OpUpdate)
|
|
return &EntityTypeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *EntityTypeClient) UpdateOne(_m *EntityType) *EntityTypeUpdateOne {
|
|
mutation := newEntityTypeMutation(c.config, OpUpdateOne, withEntityType(_m))
|
|
return &EntityTypeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *EntityTypeClient) UpdateOneID(id uuid.UUID) *EntityTypeUpdateOne {
|
|
mutation := newEntityTypeMutation(c.config, OpUpdateOne, withEntityTypeID(id))
|
|
return &EntityTypeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for EntityType.
|
|
func (c *EntityTypeClient) Delete() *EntityTypeDelete {
|
|
mutation := newEntityTypeMutation(c.config, OpDelete)
|
|
return &EntityTypeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *EntityTypeClient) DeleteOne(_m *EntityType) *EntityTypeDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *EntityTypeClient) DeleteOneID(id uuid.UUID) *EntityTypeDeleteOne {
|
|
builder := c.Delete().Where(entitytype.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &EntityTypeDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for EntityType.
|
|
func (c *EntityTypeClient) Query() *EntityTypeQuery {
|
|
return &EntityTypeQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeEntityType},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a EntityType entity by its id.
|
|
func (c *EntityTypeClient) Get(ctx context.Context, id uuid.UUID) (*EntityType, error) {
|
|
return c.Query().Where(entitytype.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *EntityTypeClient) GetX(ctx context.Context, id uuid.UUID) *EntityType {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryGroup queries the group edge of a EntityType.
|
|
func (c *EntityTypeClient) QueryGroup(_m *EntityType) *GroupQuery {
|
|
query := (&GroupClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(entitytype.Table, entitytype.FieldID, id),
|
|
sqlgraph.To(group.Table, group.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, entitytype.GroupTable, entitytype.GroupColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryEntities queries the entities edge of a EntityType.
|
|
func (c *EntityTypeClient) QueryEntities(_m *EntityType) *EntityQuery {
|
|
query := (&EntityClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(entitytype.Table, entitytype.FieldID, id),
|
|
sqlgraph.To(entity.Table, entity.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, entitytype.EntitiesTable, entitytype.EntitiesColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *EntityTypeClient) Hooks() []Hook {
|
|
return c.hooks.EntityType
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *EntityTypeClient) Interceptors() []Interceptor {
|
|
return c.inters.EntityType
|
|
}
|
|
|
|
func (c *EntityTypeClient) mutate(ctx context.Context, m *EntityTypeMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&EntityTypeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&EntityTypeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&EntityTypeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&EntityTypeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown EntityType mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// GroupClient is a client for the Group schema.
|
|
type GroupClient struct {
|
|
config
|
|
}
|
|
|
|
// NewGroupClient returns a client for the Group from the given config.
|
|
func NewGroupClient(c config) *GroupClient {
|
|
return &GroupClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `group.Hooks(f(g(h())))`.
|
|
func (c *GroupClient) Use(hooks ...Hook) {
|
|
c.hooks.Group = append(c.hooks.Group, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `group.Intercept(f(g(h())))`.
|
|
func (c *GroupClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.Group = append(c.inters.Group, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a Group entity.
|
|
func (c *GroupClient) Create() *GroupCreate {
|
|
mutation := newGroupMutation(c.config, OpCreate)
|
|
return &GroupCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of Group entities.
|
|
func (c *GroupClient) CreateBulk(builders ...*GroupCreate) *GroupCreateBulk {
|
|
return &GroupCreateBulk{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 *GroupClient) MapCreateBulk(slice any, setFunc func(*GroupCreate, int)) *GroupCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &GroupCreateBulk{err: fmt.Errorf("calling to GroupClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*GroupCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &GroupCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for Group.
|
|
func (c *GroupClient) Update() *GroupUpdate {
|
|
mutation := newGroupMutation(c.config, OpUpdate)
|
|
return &GroupUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *GroupClient) UpdateOne(_m *Group) *GroupUpdateOne {
|
|
mutation := newGroupMutation(c.config, OpUpdateOne, withGroup(_m))
|
|
return &GroupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *GroupClient) UpdateOneID(id uuid.UUID) *GroupUpdateOne {
|
|
mutation := newGroupMutation(c.config, OpUpdateOne, withGroupID(id))
|
|
return &GroupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for Group.
|
|
func (c *GroupClient) Delete() *GroupDelete {
|
|
mutation := newGroupMutation(c.config, OpDelete)
|
|
return &GroupDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *GroupClient) DeleteOne(_m *Group) *GroupDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *GroupClient) DeleteOneID(id uuid.UUID) *GroupDeleteOne {
|
|
builder := c.Delete().Where(group.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &GroupDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for Group.
|
|
func (c *GroupClient) Query() *GroupQuery {
|
|
return &GroupQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeGroup},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a Group entity by its id.
|
|
func (c *GroupClient) Get(ctx context.Context, id uuid.UUID) (*Group, error) {
|
|
return c.Query().Where(group.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *GroupClient) GetX(ctx context.Context, id uuid.UUID) *Group {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryUsers queries the users edge of a Group.
|
|
func (c *GroupClient) QueryUsers(_m *Group) *UserQuery {
|
|
query := (&UserClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(group.Table, group.FieldID, id),
|
|
sqlgraph.To(user.Table, user.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, group.UsersTable, group.UsersColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryEntities queries the entities edge of a Group.
|
|
func (c *GroupClient) QueryEntities(_m *Group) *EntityQuery {
|
|
query := (&EntityClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(group.Table, group.FieldID, id),
|
|
sqlgraph.To(entity.Table, entity.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, group.EntitiesTable, group.EntitiesColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryLabels queries the labels edge of a Group.
|
|
func (c *GroupClient) QueryLabels(_m *Group) *LabelQuery {
|
|
query := (&LabelClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(group.Table, group.FieldID, id),
|
|
sqlgraph.To(label.Table, label.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, group.LabelsTable, group.LabelsColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryInvitationTokens queries the invitation_tokens edge of a Group.
|
|
func (c *GroupClient) QueryInvitationTokens(_m *Group) *GroupInvitationTokenQuery {
|
|
query := (&GroupInvitationTokenClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(group.Table, group.FieldID, id),
|
|
sqlgraph.To(groupinvitationtoken.Table, groupinvitationtoken.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, group.InvitationTokensTable, group.InvitationTokensColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryNotifiers queries the notifiers edge of a Group.
|
|
func (c *GroupClient) QueryNotifiers(_m *Group) *NotifierQuery {
|
|
query := (&NotifierClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(group.Table, group.FieldID, id),
|
|
sqlgraph.To(notifier.Table, notifier.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, group.NotifiersTable, group.NotifiersColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryEntityTypes queries the entity_types edge of a Group.
|
|
func (c *GroupClient) QueryEntityTypes(_m *Group) *EntityTypeQuery {
|
|
query := (&EntityTypeClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(group.Table, group.FieldID, id),
|
|
sqlgraph.To(entitytype.Table, entitytype.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, group.EntityTypesTable, group.EntityTypesColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryItemTemplates queries the item_templates edge of a Group.
|
|
func (c *GroupClient) QueryItemTemplates(_m *Group) *ItemTemplateQuery {
|
|
query := (&ItemTemplateClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(group.Table, group.FieldID, id),
|
|
sqlgraph.To(itemtemplate.Table, itemtemplate.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, group.ItemTemplatesTable, group.ItemTemplatesColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *GroupClient) Hooks() []Hook {
|
|
return c.hooks.Group
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *GroupClient) Interceptors() []Interceptor {
|
|
return c.inters.Group
|
|
}
|
|
|
|
func (c *GroupClient) mutate(ctx context.Context, m *GroupMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&GroupCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&GroupUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&GroupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&GroupDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown Group mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// GroupInvitationTokenClient is a client for the GroupInvitationToken schema.
|
|
type GroupInvitationTokenClient struct {
|
|
config
|
|
}
|
|
|
|
// NewGroupInvitationTokenClient returns a client for the GroupInvitationToken from the given config.
|
|
func NewGroupInvitationTokenClient(c config) *GroupInvitationTokenClient {
|
|
return &GroupInvitationTokenClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `groupinvitationtoken.Hooks(f(g(h())))`.
|
|
func (c *GroupInvitationTokenClient) Use(hooks ...Hook) {
|
|
c.hooks.GroupInvitationToken = append(c.hooks.GroupInvitationToken, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `groupinvitationtoken.Intercept(f(g(h())))`.
|
|
func (c *GroupInvitationTokenClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.GroupInvitationToken = append(c.inters.GroupInvitationToken, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a GroupInvitationToken entity.
|
|
func (c *GroupInvitationTokenClient) Create() *GroupInvitationTokenCreate {
|
|
mutation := newGroupInvitationTokenMutation(c.config, OpCreate)
|
|
return &GroupInvitationTokenCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of GroupInvitationToken entities.
|
|
func (c *GroupInvitationTokenClient) CreateBulk(builders ...*GroupInvitationTokenCreate) *GroupInvitationTokenCreateBulk {
|
|
return &GroupInvitationTokenCreateBulk{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 *GroupInvitationTokenClient) MapCreateBulk(slice any, setFunc func(*GroupInvitationTokenCreate, int)) *GroupInvitationTokenCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &GroupInvitationTokenCreateBulk{err: fmt.Errorf("calling to GroupInvitationTokenClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*GroupInvitationTokenCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &GroupInvitationTokenCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for GroupInvitationToken.
|
|
func (c *GroupInvitationTokenClient) Update() *GroupInvitationTokenUpdate {
|
|
mutation := newGroupInvitationTokenMutation(c.config, OpUpdate)
|
|
return &GroupInvitationTokenUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *GroupInvitationTokenClient) UpdateOne(_m *GroupInvitationToken) *GroupInvitationTokenUpdateOne {
|
|
mutation := newGroupInvitationTokenMutation(c.config, OpUpdateOne, withGroupInvitationToken(_m))
|
|
return &GroupInvitationTokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *GroupInvitationTokenClient) UpdateOneID(id uuid.UUID) *GroupInvitationTokenUpdateOne {
|
|
mutation := newGroupInvitationTokenMutation(c.config, OpUpdateOne, withGroupInvitationTokenID(id))
|
|
return &GroupInvitationTokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for GroupInvitationToken.
|
|
func (c *GroupInvitationTokenClient) Delete() *GroupInvitationTokenDelete {
|
|
mutation := newGroupInvitationTokenMutation(c.config, OpDelete)
|
|
return &GroupInvitationTokenDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *GroupInvitationTokenClient) DeleteOne(_m *GroupInvitationToken) *GroupInvitationTokenDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *GroupInvitationTokenClient) DeleteOneID(id uuid.UUID) *GroupInvitationTokenDeleteOne {
|
|
builder := c.Delete().Where(groupinvitationtoken.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &GroupInvitationTokenDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for GroupInvitationToken.
|
|
func (c *GroupInvitationTokenClient) Query() *GroupInvitationTokenQuery {
|
|
return &GroupInvitationTokenQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeGroupInvitationToken},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a GroupInvitationToken entity by its id.
|
|
func (c *GroupInvitationTokenClient) Get(ctx context.Context, id uuid.UUID) (*GroupInvitationToken, error) {
|
|
return c.Query().Where(groupinvitationtoken.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *GroupInvitationTokenClient) GetX(ctx context.Context, id uuid.UUID) *GroupInvitationToken {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryGroup queries the group edge of a GroupInvitationToken.
|
|
func (c *GroupInvitationTokenClient) QueryGroup(_m *GroupInvitationToken) *GroupQuery {
|
|
query := (&GroupClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(groupinvitationtoken.Table, groupinvitationtoken.FieldID, id),
|
|
sqlgraph.To(group.Table, group.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, groupinvitationtoken.GroupTable, groupinvitationtoken.GroupColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *GroupInvitationTokenClient) Hooks() []Hook {
|
|
return c.hooks.GroupInvitationToken
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *GroupInvitationTokenClient) Interceptors() []Interceptor {
|
|
return c.inters.GroupInvitationToken
|
|
}
|
|
|
|
func (c *GroupInvitationTokenClient) mutate(ctx context.Context, m *GroupInvitationTokenMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&GroupInvitationTokenCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&GroupInvitationTokenUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&GroupInvitationTokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&GroupInvitationTokenDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown GroupInvitationToken mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// ItemTemplateClient is a client for the ItemTemplate schema.
|
|
type ItemTemplateClient struct {
|
|
config
|
|
}
|
|
|
|
// NewItemTemplateClient returns a client for the ItemTemplate from the given config.
|
|
func NewItemTemplateClient(c config) *ItemTemplateClient {
|
|
return &ItemTemplateClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `itemtemplate.Hooks(f(g(h())))`.
|
|
func (c *ItemTemplateClient) Use(hooks ...Hook) {
|
|
c.hooks.ItemTemplate = append(c.hooks.ItemTemplate, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `itemtemplate.Intercept(f(g(h())))`.
|
|
func (c *ItemTemplateClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.ItemTemplate = append(c.inters.ItemTemplate, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a ItemTemplate entity.
|
|
func (c *ItemTemplateClient) Create() *ItemTemplateCreate {
|
|
mutation := newItemTemplateMutation(c.config, OpCreate)
|
|
return &ItemTemplateCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of ItemTemplate entities.
|
|
func (c *ItemTemplateClient) CreateBulk(builders ...*ItemTemplateCreate) *ItemTemplateCreateBulk {
|
|
return &ItemTemplateCreateBulk{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 *ItemTemplateClient) MapCreateBulk(slice any, setFunc func(*ItemTemplateCreate, int)) *ItemTemplateCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &ItemTemplateCreateBulk{err: fmt.Errorf("calling to ItemTemplateClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*ItemTemplateCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &ItemTemplateCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for ItemTemplate.
|
|
func (c *ItemTemplateClient) Update() *ItemTemplateUpdate {
|
|
mutation := newItemTemplateMutation(c.config, OpUpdate)
|
|
return &ItemTemplateUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *ItemTemplateClient) UpdateOne(_m *ItemTemplate) *ItemTemplateUpdateOne {
|
|
mutation := newItemTemplateMutation(c.config, OpUpdateOne, withItemTemplate(_m))
|
|
return &ItemTemplateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *ItemTemplateClient) UpdateOneID(id uuid.UUID) *ItemTemplateUpdateOne {
|
|
mutation := newItemTemplateMutation(c.config, OpUpdateOne, withItemTemplateID(id))
|
|
return &ItemTemplateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for ItemTemplate.
|
|
func (c *ItemTemplateClient) Delete() *ItemTemplateDelete {
|
|
mutation := newItemTemplateMutation(c.config, OpDelete)
|
|
return &ItemTemplateDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *ItemTemplateClient) DeleteOne(_m *ItemTemplate) *ItemTemplateDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *ItemTemplateClient) DeleteOneID(id uuid.UUID) *ItemTemplateDeleteOne {
|
|
builder := c.Delete().Where(itemtemplate.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &ItemTemplateDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for ItemTemplate.
|
|
func (c *ItemTemplateClient) Query() *ItemTemplateQuery {
|
|
return &ItemTemplateQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeItemTemplate},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a ItemTemplate entity by its id.
|
|
func (c *ItemTemplateClient) Get(ctx context.Context, id uuid.UUID) (*ItemTemplate, error) {
|
|
return c.Query().Where(itemtemplate.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *ItemTemplateClient) GetX(ctx context.Context, id uuid.UUID) *ItemTemplate {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryGroup queries the group edge of a ItemTemplate.
|
|
func (c *ItemTemplateClient) QueryGroup(_m *ItemTemplate) *GroupQuery {
|
|
query := (&GroupClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, id),
|
|
sqlgraph.To(group.Table, group.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, itemtemplate.GroupTable, itemtemplate.GroupColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryFields queries the fields edge of a ItemTemplate.
|
|
func (c *ItemTemplateClient) QueryFields(_m *ItemTemplate) *TemplateFieldQuery {
|
|
query := (&TemplateFieldClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, id),
|
|
sqlgraph.To(templatefield.Table, templatefield.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, itemtemplate.FieldsTable, itemtemplate.FieldsColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryLocation queries the location edge of a ItemTemplate.
|
|
func (c *ItemTemplateClient) QueryLocation(_m *ItemTemplate) *EntityQuery {
|
|
query := (&EntityClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, id),
|
|
sqlgraph.To(entity.Table, entity.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, false, itemtemplate.LocationTable, itemtemplate.LocationColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *ItemTemplateClient) Hooks() []Hook {
|
|
return c.hooks.ItemTemplate
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *ItemTemplateClient) Interceptors() []Interceptor {
|
|
return c.inters.ItemTemplate
|
|
}
|
|
|
|
func (c *ItemTemplateClient) mutate(ctx context.Context, m *ItemTemplateMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&ItemTemplateCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&ItemTemplateUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&ItemTemplateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&ItemTemplateDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown ItemTemplate mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// LabelClient is a client for the Label schema.
|
|
type LabelClient struct {
|
|
config
|
|
}
|
|
|
|
// NewLabelClient returns a client for the Label from the given config.
|
|
func NewLabelClient(c config) *LabelClient {
|
|
return &LabelClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `label.Hooks(f(g(h())))`.
|
|
func (c *LabelClient) Use(hooks ...Hook) {
|
|
c.hooks.Label = append(c.hooks.Label, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `label.Intercept(f(g(h())))`.
|
|
func (c *LabelClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.Label = append(c.inters.Label, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a Label entity.
|
|
func (c *LabelClient) Create() *LabelCreate {
|
|
mutation := newLabelMutation(c.config, OpCreate)
|
|
return &LabelCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of Label entities.
|
|
func (c *LabelClient) CreateBulk(builders ...*LabelCreate) *LabelCreateBulk {
|
|
return &LabelCreateBulk{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 *LabelClient) MapCreateBulk(slice any, setFunc func(*LabelCreate, int)) *LabelCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &LabelCreateBulk{err: fmt.Errorf("calling to LabelClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*LabelCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &LabelCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for Label.
|
|
func (c *LabelClient) Update() *LabelUpdate {
|
|
mutation := newLabelMutation(c.config, OpUpdate)
|
|
return &LabelUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *LabelClient) UpdateOne(_m *Label) *LabelUpdateOne {
|
|
mutation := newLabelMutation(c.config, OpUpdateOne, withLabel(_m))
|
|
return &LabelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *LabelClient) UpdateOneID(id uuid.UUID) *LabelUpdateOne {
|
|
mutation := newLabelMutation(c.config, OpUpdateOne, withLabelID(id))
|
|
return &LabelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for Label.
|
|
func (c *LabelClient) Delete() *LabelDelete {
|
|
mutation := newLabelMutation(c.config, OpDelete)
|
|
return &LabelDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *LabelClient) DeleteOne(_m *Label) *LabelDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *LabelClient) DeleteOneID(id uuid.UUID) *LabelDeleteOne {
|
|
builder := c.Delete().Where(label.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &LabelDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for Label.
|
|
func (c *LabelClient) Query() *LabelQuery {
|
|
return &LabelQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeLabel},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a Label entity by its id.
|
|
func (c *LabelClient) Get(ctx context.Context, id uuid.UUID) (*Label, error) {
|
|
return c.Query().Where(label.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *LabelClient) GetX(ctx context.Context, id uuid.UUID) *Label {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryGroup queries the group edge of a Label.
|
|
func (c *LabelClient) QueryGroup(_m *Label) *GroupQuery {
|
|
query := (&GroupClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(label.Table, label.FieldID, id),
|
|
sqlgraph.To(group.Table, group.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, label.GroupTable, label.GroupColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryEntities queries the entities edge of a Label.
|
|
func (c *LabelClient) QueryEntities(_m *Label) *EntityQuery {
|
|
query := (&EntityClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(label.Table, label.FieldID, id),
|
|
sqlgraph.To(entity.Table, entity.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2M, false, label.EntitiesTable, label.EntitiesPrimaryKey...),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *LabelClient) Hooks() []Hook {
|
|
return c.hooks.Label
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *LabelClient) Interceptors() []Interceptor {
|
|
return c.inters.Label
|
|
}
|
|
|
|
func (c *LabelClient) mutate(ctx context.Context, m *LabelMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&LabelCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&LabelUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&LabelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&LabelDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown Label mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// MaintenanceEntryClient is a client for the MaintenanceEntry schema.
|
|
type MaintenanceEntryClient struct {
|
|
config
|
|
}
|
|
|
|
// NewMaintenanceEntryClient returns a client for the MaintenanceEntry from the given config.
|
|
func NewMaintenanceEntryClient(c config) *MaintenanceEntryClient {
|
|
return &MaintenanceEntryClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `maintenanceentry.Hooks(f(g(h())))`.
|
|
func (c *MaintenanceEntryClient) Use(hooks ...Hook) {
|
|
c.hooks.MaintenanceEntry = append(c.hooks.MaintenanceEntry, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `maintenanceentry.Intercept(f(g(h())))`.
|
|
func (c *MaintenanceEntryClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.MaintenanceEntry = append(c.inters.MaintenanceEntry, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a MaintenanceEntry entity.
|
|
func (c *MaintenanceEntryClient) Create() *MaintenanceEntryCreate {
|
|
mutation := newMaintenanceEntryMutation(c.config, OpCreate)
|
|
return &MaintenanceEntryCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of MaintenanceEntry entities.
|
|
func (c *MaintenanceEntryClient) CreateBulk(builders ...*MaintenanceEntryCreate) *MaintenanceEntryCreateBulk {
|
|
return &MaintenanceEntryCreateBulk{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 *MaintenanceEntryClient) MapCreateBulk(slice any, setFunc func(*MaintenanceEntryCreate, int)) *MaintenanceEntryCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &MaintenanceEntryCreateBulk{err: fmt.Errorf("calling to MaintenanceEntryClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*MaintenanceEntryCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &MaintenanceEntryCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for MaintenanceEntry.
|
|
func (c *MaintenanceEntryClient) Update() *MaintenanceEntryUpdate {
|
|
mutation := newMaintenanceEntryMutation(c.config, OpUpdate)
|
|
return &MaintenanceEntryUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *MaintenanceEntryClient) UpdateOne(_m *MaintenanceEntry) *MaintenanceEntryUpdateOne {
|
|
mutation := newMaintenanceEntryMutation(c.config, OpUpdateOne, withMaintenanceEntry(_m))
|
|
return &MaintenanceEntryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *MaintenanceEntryClient) UpdateOneID(id uuid.UUID) *MaintenanceEntryUpdateOne {
|
|
mutation := newMaintenanceEntryMutation(c.config, OpUpdateOne, withMaintenanceEntryID(id))
|
|
return &MaintenanceEntryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for MaintenanceEntry.
|
|
func (c *MaintenanceEntryClient) Delete() *MaintenanceEntryDelete {
|
|
mutation := newMaintenanceEntryMutation(c.config, OpDelete)
|
|
return &MaintenanceEntryDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *MaintenanceEntryClient) DeleteOne(_m *MaintenanceEntry) *MaintenanceEntryDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *MaintenanceEntryClient) DeleteOneID(id uuid.UUID) *MaintenanceEntryDeleteOne {
|
|
builder := c.Delete().Where(maintenanceentry.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &MaintenanceEntryDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for MaintenanceEntry.
|
|
func (c *MaintenanceEntryClient) Query() *MaintenanceEntryQuery {
|
|
return &MaintenanceEntryQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeMaintenanceEntry},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a MaintenanceEntry entity by its id.
|
|
func (c *MaintenanceEntryClient) Get(ctx context.Context, id uuid.UUID) (*MaintenanceEntry, error) {
|
|
return c.Query().Where(maintenanceentry.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *MaintenanceEntryClient) GetX(ctx context.Context, id uuid.UUID) *MaintenanceEntry {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryEntity queries the entity edge of a MaintenanceEntry.
|
|
func (c *MaintenanceEntryClient) QueryEntity(_m *MaintenanceEntry) *EntityQuery {
|
|
query := (&EntityClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(maintenanceentry.Table, maintenanceentry.FieldID, id),
|
|
sqlgraph.To(entity.Table, entity.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, maintenanceentry.EntityTable, maintenanceentry.EntityColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *MaintenanceEntryClient) Hooks() []Hook {
|
|
return c.hooks.MaintenanceEntry
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *MaintenanceEntryClient) Interceptors() []Interceptor {
|
|
return c.inters.MaintenanceEntry
|
|
}
|
|
|
|
func (c *MaintenanceEntryClient) mutate(ctx context.Context, m *MaintenanceEntryMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&MaintenanceEntryCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&MaintenanceEntryUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&MaintenanceEntryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&MaintenanceEntryDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown MaintenanceEntry mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// NotifierClient is a client for the Notifier schema.
|
|
type NotifierClient struct {
|
|
config
|
|
}
|
|
|
|
// NewNotifierClient returns a client for the Notifier from the given config.
|
|
func NewNotifierClient(c config) *NotifierClient {
|
|
return &NotifierClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `notifier.Hooks(f(g(h())))`.
|
|
func (c *NotifierClient) Use(hooks ...Hook) {
|
|
c.hooks.Notifier = append(c.hooks.Notifier, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `notifier.Intercept(f(g(h())))`.
|
|
func (c *NotifierClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.Notifier = append(c.inters.Notifier, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a Notifier entity.
|
|
func (c *NotifierClient) Create() *NotifierCreate {
|
|
mutation := newNotifierMutation(c.config, OpCreate)
|
|
return &NotifierCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of Notifier entities.
|
|
func (c *NotifierClient) CreateBulk(builders ...*NotifierCreate) *NotifierCreateBulk {
|
|
return &NotifierCreateBulk{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 *NotifierClient) MapCreateBulk(slice any, setFunc func(*NotifierCreate, int)) *NotifierCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &NotifierCreateBulk{err: fmt.Errorf("calling to NotifierClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*NotifierCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &NotifierCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for Notifier.
|
|
func (c *NotifierClient) Update() *NotifierUpdate {
|
|
mutation := newNotifierMutation(c.config, OpUpdate)
|
|
return &NotifierUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *NotifierClient) UpdateOne(_m *Notifier) *NotifierUpdateOne {
|
|
mutation := newNotifierMutation(c.config, OpUpdateOne, withNotifier(_m))
|
|
return &NotifierUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *NotifierClient) UpdateOneID(id uuid.UUID) *NotifierUpdateOne {
|
|
mutation := newNotifierMutation(c.config, OpUpdateOne, withNotifierID(id))
|
|
return &NotifierUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for Notifier.
|
|
func (c *NotifierClient) Delete() *NotifierDelete {
|
|
mutation := newNotifierMutation(c.config, OpDelete)
|
|
return &NotifierDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *NotifierClient) DeleteOne(_m *Notifier) *NotifierDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *NotifierClient) DeleteOneID(id uuid.UUID) *NotifierDeleteOne {
|
|
builder := c.Delete().Where(notifier.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &NotifierDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for Notifier.
|
|
func (c *NotifierClient) Query() *NotifierQuery {
|
|
return &NotifierQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeNotifier},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a Notifier entity by its id.
|
|
func (c *NotifierClient) Get(ctx context.Context, id uuid.UUID) (*Notifier, error) {
|
|
return c.Query().Where(notifier.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *NotifierClient) GetX(ctx context.Context, id uuid.UUID) *Notifier {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryGroup queries the group edge of a Notifier.
|
|
func (c *NotifierClient) QueryGroup(_m *Notifier) *GroupQuery {
|
|
query := (&GroupClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(notifier.Table, notifier.FieldID, id),
|
|
sqlgraph.To(group.Table, group.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, notifier.GroupTable, notifier.GroupColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryUser queries the user edge of a Notifier.
|
|
func (c *NotifierClient) QueryUser(_m *Notifier) *UserQuery {
|
|
query := (&UserClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(notifier.Table, notifier.FieldID, id),
|
|
sqlgraph.To(user.Table, user.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, notifier.UserTable, notifier.UserColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *NotifierClient) Hooks() []Hook {
|
|
return c.hooks.Notifier
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *NotifierClient) Interceptors() []Interceptor {
|
|
return c.inters.Notifier
|
|
}
|
|
|
|
func (c *NotifierClient) mutate(ctx context.Context, m *NotifierMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&NotifierCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&NotifierUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&NotifierUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&NotifierDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown Notifier mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// TemplateFieldClient is a client for the TemplateField schema.
|
|
type TemplateFieldClient struct {
|
|
config
|
|
}
|
|
|
|
// NewTemplateFieldClient returns a client for the TemplateField from the given config.
|
|
func NewTemplateFieldClient(c config) *TemplateFieldClient {
|
|
return &TemplateFieldClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `templatefield.Hooks(f(g(h())))`.
|
|
func (c *TemplateFieldClient) Use(hooks ...Hook) {
|
|
c.hooks.TemplateField = append(c.hooks.TemplateField, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `templatefield.Intercept(f(g(h())))`.
|
|
func (c *TemplateFieldClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.TemplateField = append(c.inters.TemplateField, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a TemplateField entity.
|
|
func (c *TemplateFieldClient) Create() *TemplateFieldCreate {
|
|
mutation := newTemplateFieldMutation(c.config, OpCreate)
|
|
return &TemplateFieldCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of TemplateField entities.
|
|
func (c *TemplateFieldClient) CreateBulk(builders ...*TemplateFieldCreate) *TemplateFieldCreateBulk {
|
|
return &TemplateFieldCreateBulk{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 *TemplateFieldClient) MapCreateBulk(slice any, setFunc func(*TemplateFieldCreate, int)) *TemplateFieldCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &TemplateFieldCreateBulk{err: fmt.Errorf("calling to TemplateFieldClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*TemplateFieldCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &TemplateFieldCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for TemplateField.
|
|
func (c *TemplateFieldClient) Update() *TemplateFieldUpdate {
|
|
mutation := newTemplateFieldMutation(c.config, OpUpdate)
|
|
return &TemplateFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *TemplateFieldClient) UpdateOne(_m *TemplateField) *TemplateFieldUpdateOne {
|
|
mutation := newTemplateFieldMutation(c.config, OpUpdateOne, withTemplateField(_m))
|
|
return &TemplateFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *TemplateFieldClient) UpdateOneID(id uuid.UUID) *TemplateFieldUpdateOne {
|
|
mutation := newTemplateFieldMutation(c.config, OpUpdateOne, withTemplateFieldID(id))
|
|
return &TemplateFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for TemplateField.
|
|
func (c *TemplateFieldClient) Delete() *TemplateFieldDelete {
|
|
mutation := newTemplateFieldMutation(c.config, OpDelete)
|
|
return &TemplateFieldDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *TemplateFieldClient) DeleteOne(_m *TemplateField) *TemplateFieldDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *TemplateFieldClient) DeleteOneID(id uuid.UUID) *TemplateFieldDeleteOne {
|
|
builder := c.Delete().Where(templatefield.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &TemplateFieldDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for TemplateField.
|
|
func (c *TemplateFieldClient) Query() *TemplateFieldQuery {
|
|
return &TemplateFieldQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeTemplateField},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a TemplateField entity by its id.
|
|
func (c *TemplateFieldClient) Get(ctx context.Context, id uuid.UUID) (*TemplateField, error) {
|
|
return c.Query().Where(templatefield.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *TemplateFieldClient) GetX(ctx context.Context, id uuid.UUID) *TemplateField {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryItemTemplate queries the item_template edge of a TemplateField.
|
|
func (c *TemplateFieldClient) QueryItemTemplate(_m *TemplateField) *ItemTemplateQuery {
|
|
query := (&ItemTemplateClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(templatefield.Table, templatefield.FieldID, id),
|
|
sqlgraph.To(itemtemplate.Table, itemtemplate.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, templatefield.ItemTemplateTable, templatefield.ItemTemplateColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *TemplateFieldClient) Hooks() []Hook {
|
|
return c.hooks.TemplateField
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *TemplateFieldClient) Interceptors() []Interceptor {
|
|
return c.inters.TemplateField
|
|
}
|
|
|
|
func (c *TemplateFieldClient) mutate(ctx context.Context, m *TemplateFieldMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&TemplateFieldCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&TemplateFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&TemplateFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&TemplateFieldDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown TemplateField mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// UserClient is a client for the User schema.
|
|
type UserClient struct {
|
|
config
|
|
}
|
|
|
|
// NewUserClient returns a client for the User from the given config.
|
|
func NewUserClient(c config) *UserClient {
|
|
return &UserClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `user.Hooks(f(g(h())))`.
|
|
func (c *UserClient) Use(hooks ...Hook) {
|
|
c.hooks.User = append(c.hooks.User, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `user.Intercept(f(g(h())))`.
|
|
func (c *UserClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.User = append(c.inters.User, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a User entity.
|
|
func (c *UserClient) Create() *UserCreate {
|
|
mutation := newUserMutation(c.config, OpCreate)
|
|
return &UserCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of User entities.
|
|
func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk {
|
|
return &UserCreateBulk{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 *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*UserCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &UserCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for User.
|
|
func (c *UserClient) Update() *UserUpdate {
|
|
mutation := newUserMutation(c.config, OpUpdate)
|
|
return &UserUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *UserClient) UpdateOne(_m *User) *UserUpdateOne {
|
|
mutation := newUserMutation(c.config, OpUpdateOne, withUser(_m))
|
|
return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *UserClient) UpdateOneID(id uuid.UUID) *UserUpdateOne {
|
|
mutation := newUserMutation(c.config, OpUpdateOne, withUserID(id))
|
|
return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for User.
|
|
func (c *UserClient) Delete() *UserDelete {
|
|
mutation := newUserMutation(c.config, OpDelete)
|
|
return &UserDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *UserClient) DeleteOne(_m *User) *UserDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *UserClient) DeleteOneID(id uuid.UUID) *UserDeleteOne {
|
|
builder := c.Delete().Where(user.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &UserDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for User.
|
|
func (c *UserClient) Query() *UserQuery {
|
|
return &UserQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeUser},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a User entity by its id.
|
|
func (c *UserClient) Get(ctx context.Context, id uuid.UUID) (*User, error) {
|
|
return c.Query().Where(user.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *UserClient) GetX(ctx context.Context, id uuid.UUID) *User {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryGroup queries the group edge of a User.
|
|
func (c *UserClient) QueryGroup(_m *User) *GroupQuery {
|
|
query := (&GroupClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(user.Table, user.FieldID, id),
|
|
sqlgraph.To(group.Table, group.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, user.GroupTable, user.GroupColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryAuthTokens queries the auth_tokens edge of a User.
|
|
func (c *UserClient) QueryAuthTokens(_m *User) *AuthTokensQuery {
|
|
query := (&AuthTokensClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(user.Table, user.FieldID, id),
|
|
sqlgraph.To(authtokens.Table, authtokens.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, user.AuthTokensTable, user.AuthTokensColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryNotifiers queries the notifiers edge of a User.
|
|
func (c *UserClient) QueryNotifiers(_m *User) *NotifierQuery {
|
|
query := (&NotifierClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(user.Table, user.FieldID, id),
|
|
sqlgraph.To(notifier.Table, notifier.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, user.NotifiersTable, user.NotifiersColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *UserClient) Hooks() []Hook {
|
|
return c.hooks.User
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *UserClient) Interceptors() []Interceptor {
|
|
return c.inters.User
|
|
}
|
|
|
|
func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&UserCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&UserUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&UserDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown User mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// hooks and interceptors per client, for fast access.
|
|
type (
|
|
hooks struct {
|
|
Attachment, AuthRoles, AuthTokens, Entity, EntityField, EntityType, Group,
|
|
GroupInvitationToken, ItemTemplate, Label, MaintenanceEntry, Notifier,
|
|
TemplateField, User []ent.Hook
|
|
}
|
|
inters struct {
|
|
Attachment, AuthRoles, AuthTokens, Entity, EntityField, EntityType, Group,
|
|
GroupInvitationToken, ItemTemplate, Label, MaintenanceEntry, Notifier,
|
|
TemplateField, User []ent.Interceptor
|
|
}
|
|
)
|