mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-24 06:28:34 +01:00
* feat: Add item templates feature (#435) Add ability to create and manage item templates for quick item creation. Templates store default values and custom fields that can be applied when creating new items. Backend changes: - New ItemTemplate and TemplateField Ent schemas - Template CRUD API endpoints - Create item from template endpoint Frontend changes: - Templates management page with create/edit/delete - Template selector in item creation modal - 'Use as Template' action on item detail page - Templates link in navigation menu * refactor: Improve template item creation with a single query - Add `CreateFromTemplate` method to ItemsRepository that creates items with all template data (including custom fields) in a single atomic transaction, replacing the previous two-phase create-then-update pattern - Fix `GetOne` to require group ID parameter so templates can only be accessed by users in the owning group (security fix) - Simplify `HandleItemTemplatesCreateItem` handler using the new transactional method * Refactor item template types and formatting Updated type annotations in CreateModal.vue to use specific ItemTemplate types instead of 'any'. Improved code formatting for template fields and manufacturer display. Also refactored warranty field logic in item details page for better readability. This resolves the linter issues as well that the bot in github keeps nagging at. * Add 'id' property to template fields Introduces an 'id' property to each field object in CreateModal.vue and item details page to support unique identification of fields. This change prepares the codebase for future enhancements that may require field-level identification. * Removed redundant SQL migrations. Removed redundant SQL migrations per @tankerkiller125's findings. * Updates to PR #1099. Regarding pull #1099. Fixed an issue causing some conflict with GUIDs and old rows in the migration files. * Add new fields and location edge to ItemTemplate Addresses recommendations from @tonyaellie. * Relocated add template button * Added more default fields to the template * Added translation of all strings (think so?) * Make oval buttons round * Added duplicate button to the template (this required a rewrite of the migration files, I made sure only 1 exists per DB type) * Added a Save as template button to a item detail view (this creates a template with all the current data of that item) * Changed all occurrences of space to gap and flex where applicable. * Made template selection persistent after item created. * Collapsible template info on creation view. * Updates to translation and fix for labels/locations I also added a test in here because I keep missing small function tests. That should prevent that from happening again. * Linted * Bring up to date with main, fix some lint/type check issues * In theory fix playwright tests * Fix defaults being unable to be nullable/empty (and thus limiting flexibility) * Last few fixes I think * Forgot to fix the golang tests --------- Co-authored-by: Matthew Kilgore <matthew@kilgore.dev>
2800 lines
101 KiB
Go
Generated
2800 lines
101 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/group"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
|
|
"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/location"
|
|
"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
|
|
// Group is the client for interacting with the Group builders.
|
|
Group *GroupClient
|
|
// GroupInvitationToken is the client for interacting with the GroupInvitationToken builders.
|
|
GroupInvitationToken *GroupInvitationTokenClient
|
|
// Item is the client for interacting with the Item builders.
|
|
Item *ItemClient
|
|
// ItemField is the client for interacting with the ItemField builders.
|
|
ItemField *ItemFieldClient
|
|
// ItemTemplate is the client for interacting with the ItemTemplate builders.
|
|
ItemTemplate *ItemTemplateClient
|
|
// Label is the client for interacting with the Label builders.
|
|
Label *LabelClient
|
|
// Location is the client for interacting with the Location builders.
|
|
Location *LocationClient
|
|
// 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.Group = NewGroupClient(c.config)
|
|
c.GroupInvitationToken = NewGroupInvitationTokenClient(c.config)
|
|
c.Item = NewItemClient(c.config)
|
|
c.ItemField = NewItemFieldClient(c.config)
|
|
c.ItemTemplate = NewItemTemplateClient(c.config)
|
|
c.Label = NewLabelClient(c.config)
|
|
c.Location = NewLocationClient(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),
|
|
Group: NewGroupClient(cfg),
|
|
GroupInvitationToken: NewGroupInvitationTokenClient(cfg),
|
|
Item: NewItemClient(cfg),
|
|
ItemField: NewItemFieldClient(cfg),
|
|
ItemTemplate: NewItemTemplateClient(cfg),
|
|
Label: NewLabelClient(cfg),
|
|
Location: NewLocationClient(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),
|
|
Group: NewGroupClient(cfg),
|
|
GroupInvitationToken: NewGroupInvitationTokenClient(cfg),
|
|
Item: NewItemClient(cfg),
|
|
ItemField: NewItemFieldClient(cfg),
|
|
ItemTemplate: NewItemTemplateClient(cfg),
|
|
Label: NewLabelClient(cfg),
|
|
Location: NewLocationClient(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.Group, c.GroupInvitationToken,
|
|
c.Item, c.ItemField, c.ItemTemplate, c.Label, c.Location, 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.Group, c.GroupInvitationToken,
|
|
c.Item, c.ItemField, c.ItemTemplate, c.Label, c.Location, 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 *GroupMutation:
|
|
return c.Group.mutate(ctx, m)
|
|
case *GroupInvitationTokenMutation:
|
|
return c.GroupInvitationToken.mutate(ctx, m)
|
|
case *ItemMutation:
|
|
return c.Item.mutate(ctx, m)
|
|
case *ItemFieldMutation:
|
|
return c.ItemField.mutate(ctx, m)
|
|
case *ItemTemplateMutation:
|
|
return c.ItemTemplate.mutate(ctx, m)
|
|
case *LabelMutation:
|
|
return c.Label.mutate(ctx, m)
|
|
case *LocationMutation:
|
|
return c.Location.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
|
|
}
|
|
|
|
// QueryItem queries the item edge of a Attachment.
|
|
func (c *AttachmentClient) QueryItem(_m *Attachment) *ItemQuery {
|
|
query := (&ItemClient{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(item.Table, item.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, attachment.ItemTable, attachment.ItemColumn),
|
|
)
|
|
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())
|
|
}
|
|
}
|
|
|
|
// 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
|
|
}
|
|
|
|
// QueryLocations queries the locations edge of a Group.
|
|
func (c *GroupClient) QueryLocations(_m *Group) *LocationQuery {
|
|
query := (&LocationClient{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(location.Table, location.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, group.LocationsTable, group.LocationsColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryItems queries the items edge of a Group.
|
|
func (c *GroupClient) QueryItems(_m *Group) *ItemQuery {
|
|
query := (&ItemClient{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(item.Table, item.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, group.ItemsTable, group.ItemsColumn),
|
|
)
|
|
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
|
|
}
|
|
|
|
// 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())
|
|
}
|
|
}
|
|
|
|
// ItemClient is a client for the Item schema.
|
|
type ItemClient struct {
|
|
config
|
|
}
|
|
|
|
// NewItemClient returns a client for the Item from the given config.
|
|
func NewItemClient(c config) *ItemClient {
|
|
return &ItemClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `item.Hooks(f(g(h())))`.
|
|
func (c *ItemClient) Use(hooks ...Hook) {
|
|
c.hooks.Item = append(c.hooks.Item, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `item.Intercept(f(g(h())))`.
|
|
func (c *ItemClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.Item = append(c.inters.Item, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a Item entity.
|
|
func (c *ItemClient) Create() *ItemCreate {
|
|
mutation := newItemMutation(c.config, OpCreate)
|
|
return &ItemCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of Item entities.
|
|
func (c *ItemClient) CreateBulk(builders ...*ItemCreate) *ItemCreateBulk {
|
|
return &ItemCreateBulk{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 *ItemClient) MapCreateBulk(slice any, setFunc func(*ItemCreate, int)) *ItemCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &ItemCreateBulk{err: fmt.Errorf("calling to ItemClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*ItemCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &ItemCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for Item.
|
|
func (c *ItemClient) Update() *ItemUpdate {
|
|
mutation := newItemMutation(c.config, OpUpdate)
|
|
return &ItemUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *ItemClient) UpdateOne(_m *Item) *ItemUpdateOne {
|
|
mutation := newItemMutation(c.config, OpUpdateOne, withItem(_m))
|
|
return &ItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *ItemClient) UpdateOneID(id uuid.UUID) *ItemUpdateOne {
|
|
mutation := newItemMutation(c.config, OpUpdateOne, withItemID(id))
|
|
return &ItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for Item.
|
|
func (c *ItemClient) Delete() *ItemDelete {
|
|
mutation := newItemMutation(c.config, OpDelete)
|
|
return &ItemDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *ItemClient) DeleteOne(_m *Item) *ItemDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *ItemClient) DeleteOneID(id uuid.UUID) *ItemDeleteOne {
|
|
builder := c.Delete().Where(item.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &ItemDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for Item.
|
|
func (c *ItemClient) Query() *ItemQuery {
|
|
return &ItemQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeItem},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a Item entity by its id.
|
|
func (c *ItemClient) Get(ctx context.Context, id uuid.UUID) (*Item, error) {
|
|
return c.Query().Where(item.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *ItemClient) GetX(ctx context.Context, id uuid.UUID) *Item {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryGroup queries the group edge of a Item.
|
|
func (c *ItemClient) QueryGroup(_m *Item) *GroupQuery {
|
|
query := (&GroupClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(item.Table, item.FieldID, id),
|
|
sqlgraph.To(group.Table, group.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, item.GroupTable, item.GroupColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryParent queries the parent edge of a Item.
|
|
func (c *ItemClient) QueryParent(_m *Item) *ItemQuery {
|
|
query := (&ItemClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(item.Table, item.FieldID, id),
|
|
sqlgraph.To(item.Table, item.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, item.ParentTable, item.ParentColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryChildren queries the children edge of a Item.
|
|
func (c *ItemClient) QueryChildren(_m *Item) *ItemQuery {
|
|
query := (&ItemClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(item.Table, item.FieldID, id),
|
|
sqlgraph.To(item.Table, item.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, item.ChildrenTable, item.ChildrenColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryLabel queries the label edge of a Item.
|
|
func (c *ItemClient) QueryLabel(_m *Item) *LabelQuery {
|
|
query := (&LabelClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(item.Table, item.FieldID, id),
|
|
sqlgraph.To(label.Table, label.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2M, true, item.LabelTable, item.LabelPrimaryKey...),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryLocation queries the location edge of a Item.
|
|
func (c *ItemClient) QueryLocation(_m *Item) *LocationQuery {
|
|
query := (&LocationClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(item.Table, item.FieldID, id),
|
|
sqlgraph.To(location.Table, location.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, item.LocationTable, item.LocationColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryFields queries the fields edge of a Item.
|
|
func (c *ItemClient) QueryFields(_m *Item) *ItemFieldQuery {
|
|
query := (&ItemFieldClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(item.Table, item.FieldID, id),
|
|
sqlgraph.To(itemfield.Table, itemfield.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, item.FieldsTable, item.FieldsColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryMaintenanceEntries queries the maintenance_entries edge of a Item.
|
|
func (c *ItemClient) QueryMaintenanceEntries(_m *Item) *MaintenanceEntryQuery {
|
|
query := (&MaintenanceEntryClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(item.Table, item.FieldID, id),
|
|
sqlgraph.To(maintenanceentry.Table, maintenanceentry.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, item.MaintenanceEntriesTable, item.MaintenanceEntriesColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryAttachments queries the attachments edge of a Item.
|
|
func (c *ItemClient) QueryAttachments(_m *Item) *AttachmentQuery {
|
|
query := (&AttachmentClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(item.Table, item.FieldID, id),
|
|
sqlgraph.To(attachment.Table, attachment.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, item.AttachmentsTable, item.AttachmentsColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *ItemClient) Hooks() []Hook {
|
|
return c.hooks.Item
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *ItemClient) Interceptors() []Interceptor {
|
|
return c.inters.Item
|
|
}
|
|
|
|
func (c *ItemClient) mutate(ctx context.Context, m *ItemMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&ItemCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&ItemUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&ItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&ItemDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown Item mutation op: %q", m.Op())
|
|
}
|
|
}
|
|
|
|
// ItemFieldClient is a client for the ItemField schema.
|
|
type ItemFieldClient struct {
|
|
config
|
|
}
|
|
|
|
// NewItemFieldClient returns a client for the ItemField from the given config.
|
|
func NewItemFieldClient(c config) *ItemFieldClient {
|
|
return &ItemFieldClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `itemfield.Hooks(f(g(h())))`.
|
|
func (c *ItemFieldClient) Use(hooks ...Hook) {
|
|
c.hooks.ItemField = append(c.hooks.ItemField, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `itemfield.Intercept(f(g(h())))`.
|
|
func (c *ItemFieldClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.ItemField = append(c.inters.ItemField, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a ItemField entity.
|
|
func (c *ItemFieldClient) Create() *ItemFieldCreate {
|
|
mutation := newItemFieldMutation(c.config, OpCreate)
|
|
return &ItemFieldCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of ItemField entities.
|
|
func (c *ItemFieldClient) CreateBulk(builders ...*ItemFieldCreate) *ItemFieldCreateBulk {
|
|
return &ItemFieldCreateBulk{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 *ItemFieldClient) MapCreateBulk(slice any, setFunc func(*ItemFieldCreate, int)) *ItemFieldCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &ItemFieldCreateBulk{err: fmt.Errorf("calling to ItemFieldClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*ItemFieldCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &ItemFieldCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for ItemField.
|
|
func (c *ItemFieldClient) Update() *ItemFieldUpdate {
|
|
mutation := newItemFieldMutation(c.config, OpUpdate)
|
|
return &ItemFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *ItemFieldClient) UpdateOne(_m *ItemField) *ItemFieldUpdateOne {
|
|
mutation := newItemFieldMutation(c.config, OpUpdateOne, withItemField(_m))
|
|
return &ItemFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *ItemFieldClient) UpdateOneID(id uuid.UUID) *ItemFieldUpdateOne {
|
|
mutation := newItemFieldMutation(c.config, OpUpdateOne, withItemFieldID(id))
|
|
return &ItemFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for ItemField.
|
|
func (c *ItemFieldClient) Delete() *ItemFieldDelete {
|
|
mutation := newItemFieldMutation(c.config, OpDelete)
|
|
return &ItemFieldDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *ItemFieldClient) DeleteOne(_m *ItemField) *ItemFieldDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *ItemFieldClient) DeleteOneID(id uuid.UUID) *ItemFieldDeleteOne {
|
|
builder := c.Delete().Where(itemfield.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &ItemFieldDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for ItemField.
|
|
func (c *ItemFieldClient) Query() *ItemFieldQuery {
|
|
return &ItemFieldQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeItemField},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a ItemField entity by its id.
|
|
func (c *ItemFieldClient) Get(ctx context.Context, id uuid.UUID) (*ItemField, error) {
|
|
return c.Query().Where(itemfield.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *ItemFieldClient) GetX(ctx context.Context, id uuid.UUID) *ItemField {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryItem queries the item edge of a ItemField.
|
|
func (c *ItemFieldClient) QueryItem(_m *ItemField) *ItemQuery {
|
|
query := (&ItemClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(itemfield.Table, itemfield.FieldID, id),
|
|
sqlgraph.To(item.Table, item.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, itemfield.ItemTable, itemfield.ItemColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *ItemFieldClient) Hooks() []Hook {
|
|
return c.hooks.ItemField
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *ItemFieldClient) Interceptors() []Interceptor {
|
|
return c.inters.ItemField
|
|
}
|
|
|
|
func (c *ItemFieldClient) mutate(ctx context.Context, m *ItemFieldMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&ItemFieldCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&ItemFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&ItemFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&ItemFieldDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown ItemField 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) *LocationQuery {
|
|
query := (&LocationClient{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(location.Table, location.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
|
|
}
|
|
|
|
// QueryItems queries the items edge of a Label.
|
|
func (c *LabelClient) QueryItems(_m *Label) *ItemQuery {
|
|
query := (&ItemClient{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(item.Table, item.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2M, false, label.ItemsTable, label.ItemsPrimaryKey...),
|
|
)
|
|
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())
|
|
}
|
|
}
|
|
|
|
// LocationClient is a client for the Location schema.
|
|
type LocationClient struct {
|
|
config
|
|
}
|
|
|
|
// NewLocationClient returns a client for the Location from the given config.
|
|
func NewLocationClient(c config) *LocationClient {
|
|
return &LocationClient{config: c}
|
|
}
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
// A call to `Use(f, g, h)` equals to `location.Hooks(f(g(h())))`.
|
|
func (c *LocationClient) Use(hooks ...Hook) {
|
|
c.hooks.Location = append(c.hooks.Location, hooks...)
|
|
}
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
// A call to `Intercept(f, g, h)` equals to `location.Intercept(f(g(h())))`.
|
|
func (c *LocationClient) Intercept(interceptors ...Interceptor) {
|
|
c.inters.Location = append(c.inters.Location, interceptors...)
|
|
}
|
|
|
|
// Create returns a builder for creating a Location entity.
|
|
func (c *LocationClient) Create() *LocationCreate {
|
|
mutation := newLocationMutation(c.config, OpCreate)
|
|
return &LocationCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// CreateBulk returns a builder for creating a bulk of Location entities.
|
|
func (c *LocationClient) CreateBulk(builders ...*LocationCreate) *LocationCreateBulk {
|
|
return &LocationCreateBulk{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 *LocationClient) MapCreateBulk(slice any, setFunc func(*LocationCreate, int)) *LocationCreateBulk {
|
|
rv := reflect.ValueOf(slice)
|
|
if rv.Kind() != reflect.Slice {
|
|
return &LocationCreateBulk{err: fmt.Errorf("calling to LocationClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
}
|
|
builders := make([]*LocationCreate, rv.Len())
|
|
for i := 0; i < rv.Len(); i++ {
|
|
builders[i] = c.Create()
|
|
setFunc(builders[i], i)
|
|
}
|
|
return &LocationCreateBulk{config: c.config, builders: builders}
|
|
}
|
|
|
|
// Update returns an update builder for Location.
|
|
func (c *LocationClient) Update() *LocationUpdate {
|
|
mutation := newLocationMutation(c.config, OpUpdate)
|
|
return &LocationUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
func (c *LocationClient) UpdateOne(_m *Location) *LocationUpdateOne {
|
|
mutation := newLocationMutation(c.config, OpUpdateOne, withLocation(_m))
|
|
return &LocationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
func (c *LocationClient) UpdateOneID(id uuid.UUID) *LocationUpdateOne {
|
|
mutation := newLocationMutation(c.config, OpUpdateOne, withLocationID(id))
|
|
return &LocationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// Delete returns a delete builder for Location.
|
|
func (c *LocationClient) Delete() *LocationDelete {
|
|
mutation := newLocationMutation(c.config, OpDelete)
|
|
return &LocationDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
}
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
func (c *LocationClient) DeleteOne(_m *Location) *LocationDeleteOne {
|
|
return c.DeleteOneID(_m.ID)
|
|
}
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
func (c *LocationClient) DeleteOneID(id uuid.UUID) *LocationDeleteOne {
|
|
builder := c.Delete().Where(location.ID(id))
|
|
builder.mutation.id = &id
|
|
builder.mutation.op = OpDeleteOne
|
|
return &LocationDeleteOne{builder}
|
|
}
|
|
|
|
// Query returns a query builder for Location.
|
|
func (c *LocationClient) Query() *LocationQuery {
|
|
return &LocationQuery{
|
|
config: c.config,
|
|
ctx: &QueryContext{Type: TypeLocation},
|
|
inters: c.Interceptors(),
|
|
}
|
|
}
|
|
|
|
// Get returns a Location entity by its id.
|
|
func (c *LocationClient) Get(ctx context.Context, id uuid.UUID) (*Location, error) {
|
|
return c.Query().Where(location.ID(id)).Only(ctx)
|
|
}
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
func (c *LocationClient) GetX(ctx context.Context, id uuid.UUID) *Location {
|
|
obj, err := c.Get(ctx, id)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return obj
|
|
}
|
|
|
|
// QueryGroup queries the group edge of a Location.
|
|
func (c *LocationClient) QueryGroup(_m *Location) *GroupQuery {
|
|
query := (&GroupClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(location.Table, location.FieldID, id),
|
|
sqlgraph.To(group.Table, group.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, location.GroupTable, location.GroupColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryParent queries the parent edge of a Location.
|
|
func (c *LocationClient) QueryParent(_m *Location) *LocationQuery {
|
|
query := (&LocationClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(location.Table, location.FieldID, id),
|
|
sqlgraph.To(location.Table, location.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, location.ParentTable, location.ParentColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryChildren queries the children edge of a Location.
|
|
func (c *LocationClient) QueryChildren(_m *Location) *LocationQuery {
|
|
query := (&LocationClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(location.Table, location.FieldID, id),
|
|
sqlgraph.To(location.Table, location.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, location.ChildrenTable, location.ChildrenColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// QueryItems queries the items edge of a Location.
|
|
func (c *LocationClient) QueryItems(_m *Location) *ItemQuery {
|
|
query := (&ItemClient{config: c.config}).Query()
|
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
|
id := _m.ID
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(location.Table, location.FieldID, id),
|
|
sqlgraph.To(item.Table, item.FieldID),
|
|
sqlgraph.Edge(sqlgraph.O2M, false, location.ItemsTable, location.ItemsColumn),
|
|
)
|
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
|
return fromV, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// Hooks returns the client hooks.
|
|
func (c *LocationClient) Hooks() []Hook {
|
|
return c.hooks.Location
|
|
}
|
|
|
|
// Interceptors returns the client interceptors.
|
|
func (c *LocationClient) Interceptors() []Interceptor {
|
|
return c.inters.Location
|
|
}
|
|
|
|
func (c *LocationClient) mutate(ctx context.Context, m *LocationMutation) (Value, error) {
|
|
switch m.Op() {
|
|
case OpCreate:
|
|
return (&LocationCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdate:
|
|
return (&LocationUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpUpdateOne:
|
|
return (&LocationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
case OpDelete, OpDeleteOne:
|
|
return (&LocationDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("ent: unknown Location 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
|
|
}
|
|
|
|
// QueryItem queries the item edge of a MaintenanceEntry.
|
|
func (c *MaintenanceEntryClient) QueryItem(_m *MaintenanceEntry) *ItemQuery {
|
|
query := (&ItemClient{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(item.Table, item.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, maintenanceentry.ItemTable, maintenanceentry.ItemColumn),
|
|
)
|
|
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, Group, GroupInvitationToken, Item, ItemField,
|
|
ItemTemplate, Label, Location, MaintenanceEntry, Notifier, TemplateField,
|
|
User []ent.Hook
|
|
}
|
|
inters struct {
|
|
Attachment, AuthRoles, AuthTokens, Group, GroupInvitationToken, Item, ItemField,
|
|
ItemTemplate, Label, Location, MaintenanceEntry, Notifier, TemplateField,
|
|
User []ent.Interceptor
|
|
}
|
|
)
|