// Code generated by ent, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "log" "github.com/google/uuid" "github.com/hay-kot/homebox/backend/internal/data/ent/migrate" "github.com/hay-kot/homebox/backend/internal/data/ent/attachment" "github.com/hay-kot/homebox/backend/internal/data/ent/authroles" "github.com/hay-kot/homebox/backend/internal/data/ent/authtokens" "github.com/hay-kot/homebox/backend/internal/data/ent/document" "github.com/hay-kot/homebox/backend/internal/data/ent/group" "github.com/hay-kot/homebox/backend/internal/data/ent/groupinvitationtoken" "github.com/hay-kot/homebox/backend/internal/data/ent/item" "github.com/hay-kot/homebox/backend/internal/data/ent/itemfield" "github.com/hay-kot/homebox/backend/internal/data/ent/label" "github.com/hay-kot/homebox/backend/internal/data/ent/location" "github.com/hay-kot/homebox/backend/internal/data/ent/maintenanceentry" "github.com/hay-kot/homebox/backend/internal/data/ent/user" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" ) // 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 // Document is the client for interacting with the Document builders. Document *DocumentClient // 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 // 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 // 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 { cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} cfg.options(opts...) client := &Client{config: cfg} 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.Document = NewDocumentClient(c.config) c.Group = NewGroupClient(c.config) c.GroupInvitationToken = NewGroupInvitationTokenClient(c.config) c.Item = NewItemClient(c.config) c.ItemField = NewItemFieldClient(c.config) c.Label = NewLabelClient(c.config) c.Location = NewLocationClient(c.config) c.MaintenanceEntry = NewMaintenanceEntryClient(c.config) c.User = NewUserClient(c.config) } // 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) } } // 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, errors.New("ent: cannot start a transaction within a transaction") } 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), Document: NewDocumentClient(cfg), Group: NewGroupClient(cfg), GroupInvitationToken: NewGroupInvitationTokenClient(cfg), Item: NewItemClient(cfg), ItemField: NewItemFieldClient(cfg), Label: NewLabelClient(cfg), Location: NewLocationClient(cfg), MaintenanceEntry: NewMaintenanceEntryClient(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), Document: NewDocumentClient(cfg), Group: NewGroupClient(cfg), GroupInvitationToken: NewGroupInvitationTokenClient(cfg), Item: NewItemClient(cfg), ItemField: NewItemFieldClient(cfg), Label: NewLabelClient(cfg), Location: NewLocationClient(cfg), MaintenanceEntry: NewMaintenanceEntryClient(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) { c.Attachment.Use(hooks...) c.AuthRoles.Use(hooks...) c.AuthTokens.Use(hooks...) c.Document.Use(hooks...) c.Group.Use(hooks...) c.GroupInvitationToken.Use(hooks...) c.Item.Use(hooks...) c.ItemField.Use(hooks...) c.Label.Use(hooks...) c.Location.Use(hooks...) c.MaintenanceEntry.Use(hooks...) c.User.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) { c.Attachment.Intercept(interceptors...) c.AuthRoles.Intercept(interceptors...) c.AuthTokens.Intercept(interceptors...) c.Document.Intercept(interceptors...) c.Group.Intercept(interceptors...) c.GroupInvitationToken.Intercept(interceptors...) c.Item.Intercept(interceptors...) c.ItemField.Intercept(interceptors...) c.Label.Intercept(interceptors...) c.Location.Intercept(interceptors...) c.MaintenanceEntry.Intercept(interceptors...) c.User.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 *DocumentMutation: return c.Document.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 *LabelMutation: return c.Label.mutate(ctx, m) case *LocationMutation: return c.Location.mutate(ctx, m) case *MaintenanceEntryMutation: return c.MaintenanceEntry.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...) } // Use 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} } // 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(a *Attachment) *AttachmentUpdateOne { mutation := newAttachmentMutation(c.config, OpUpdateOne, withAttachment(a)) 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(a *Attachment) *AttachmentDeleteOne { return c.DeleteOneID(a.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(a *Attachment) *ItemQuery { query := (&ItemClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := a.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(a.driver.Dialect(), step) return fromV, nil } return query } // QueryDocument queries the document edge of a Attachment. func (c *AttachmentClient) QueryDocument(a *Attachment) *DocumentQuery { query := (&DocumentClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := a.ID step := sqlgraph.NewStep( sqlgraph.From(attachment.Table, attachment.FieldID, id), sqlgraph.To(document.Table, document.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, attachment.DocumentTable, attachment.DocumentColumn), ) fromV = sqlgraph.Neighbors(a.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...) } // Use 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} } // 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(ar *AuthRoles) *AuthRolesUpdateOne { mutation := newAuthRolesMutation(c.config, OpUpdateOne, withAuthRoles(ar)) 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(ar *AuthRoles) *AuthRolesDeleteOne { return c.DeleteOneID(ar.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(ar *AuthRoles) *AuthTokensQuery { query := (&AuthTokensClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := ar.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(ar.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...) } // Use 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} } // 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(at *AuthTokens) *AuthTokensUpdateOne { mutation := newAuthTokensMutation(c.config, OpUpdateOne, withAuthTokens(at)) 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(at *AuthTokens) *AuthTokensDeleteOne { return c.DeleteOneID(at.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(at *AuthTokens) *UserQuery { query := (&UserClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := at.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(at.driver.Dialect(), step) return fromV, nil } return query } // QueryRoles queries the roles edge of a AuthTokens. func (c *AuthTokensClient) QueryRoles(at *AuthTokens) *AuthRolesQuery { query := (&AuthRolesClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := at.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(at.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()) } } // DocumentClient is a client for the Document schema. type DocumentClient struct { config } // NewDocumentClient returns a client for the Document from the given config. func NewDocumentClient(c config) *DocumentClient { return &DocumentClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `document.Hooks(f(g(h())))`. func (c *DocumentClient) Use(hooks ...Hook) { c.hooks.Document = append(c.hooks.Document, hooks...) } // Use adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `document.Intercept(f(g(h())))`. func (c *DocumentClient) Intercept(interceptors ...Interceptor) { c.inters.Document = append(c.inters.Document, interceptors...) } // Create returns a builder for creating a Document entity. func (c *DocumentClient) Create() *DocumentCreate { mutation := newDocumentMutation(c.config, OpCreate) return &DocumentCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Document entities. func (c *DocumentClient) CreateBulk(builders ...*DocumentCreate) *DocumentCreateBulk { return &DocumentCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Document. func (c *DocumentClient) Update() *DocumentUpdate { mutation := newDocumentMutation(c.config, OpUpdate) return &DocumentUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *DocumentClient) UpdateOne(d *Document) *DocumentUpdateOne { mutation := newDocumentMutation(c.config, OpUpdateOne, withDocument(d)) return &DocumentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *DocumentClient) UpdateOneID(id uuid.UUID) *DocumentUpdateOne { mutation := newDocumentMutation(c.config, OpUpdateOne, withDocumentID(id)) return &DocumentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Document. func (c *DocumentClient) Delete() *DocumentDelete { mutation := newDocumentMutation(c.config, OpDelete) return &DocumentDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *DocumentClient) DeleteOne(d *Document) *DocumentDeleteOne { return c.DeleteOneID(d.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *DocumentClient) DeleteOneID(id uuid.UUID) *DocumentDeleteOne { builder := c.Delete().Where(document.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &DocumentDeleteOne{builder} } // Query returns a query builder for Document. func (c *DocumentClient) Query() *DocumentQuery { return &DocumentQuery{ config: c.config, ctx: &QueryContext{Type: TypeDocument}, inters: c.Interceptors(), } } // Get returns a Document entity by its id. func (c *DocumentClient) Get(ctx context.Context, id uuid.UUID) (*Document, error) { return c.Query().Where(document.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *DocumentClient) GetX(ctx context.Context, id uuid.UUID) *Document { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryGroup queries the group edge of a Document. func (c *DocumentClient) QueryGroup(d *Document) *GroupQuery { query := (&GroupClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := d.ID step := sqlgraph.NewStep( sqlgraph.From(document.Table, document.FieldID, id), sqlgraph.To(group.Table, group.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, document.GroupTable, document.GroupColumn), ) fromV = sqlgraph.Neighbors(d.driver.Dialect(), step) return fromV, nil } return query } // QueryAttachments queries the attachments edge of a Document. func (c *DocumentClient) QueryAttachments(d *Document) *AttachmentQuery { query := (&AttachmentClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := d.ID step := sqlgraph.NewStep( sqlgraph.From(document.Table, document.FieldID, id), sqlgraph.To(attachment.Table, attachment.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, document.AttachmentsTable, document.AttachmentsColumn), ) fromV = sqlgraph.Neighbors(d.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *DocumentClient) Hooks() []Hook { return c.hooks.Document } // Interceptors returns the client interceptors. func (c *DocumentClient) Interceptors() []Interceptor { return c.inters.Document } func (c *DocumentClient) mutate(ctx context.Context, m *DocumentMutation) (Value, error) { switch m.Op() { case OpCreate: return (&DocumentCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&DocumentUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&DocumentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&DocumentDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Document 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...) } // Use 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} } // 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(gr *Group) *GroupUpdateOne { mutation := newGroupMutation(c.config, OpUpdateOne, withGroup(gr)) 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(gr *Group) *GroupDeleteOne { return c.DeleteOneID(gr.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(gr *Group) *UserQuery { query := (&UserClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := gr.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(gr.driver.Dialect(), step) return fromV, nil } return query } // QueryLocations queries the locations edge of a Group. func (c *GroupClient) QueryLocations(gr *Group) *LocationQuery { query := (&LocationClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := gr.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(gr.driver.Dialect(), step) return fromV, nil } return query } // QueryItems queries the items edge of a Group. func (c *GroupClient) QueryItems(gr *Group) *ItemQuery { query := (&ItemClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := gr.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(gr.driver.Dialect(), step) return fromV, nil } return query } // QueryLabels queries the labels edge of a Group. func (c *GroupClient) QueryLabels(gr *Group) *LabelQuery { query := (&LabelClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := gr.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(gr.driver.Dialect(), step) return fromV, nil } return query } // QueryDocuments queries the documents edge of a Group. func (c *GroupClient) QueryDocuments(gr *Group) *DocumentQuery { query := (&DocumentClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := gr.ID step := sqlgraph.NewStep( sqlgraph.From(group.Table, group.FieldID, id), sqlgraph.To(document.Table, document.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, group.DocumentsTable, group.DocumentsColumn), ) fromV = sqlgraph.Neighbors(gr.driver.Dialect(), step) return fromV, nil } return query } // QueryInvitationTokens queries the invitation_tokens edge of a Group. func (c *GroupClient) QueryInvitationTokens(gr *Group) *GroupInvitationTokenQuery { query := (&GroupInvitationTokenClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := gr.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(gr.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...) } // Use 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} } // 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(git *GroupInvitationToken) *GroupInvitationTokenUpdateOne { mutation := newGroupInvitationTokenMutation(c.config, OpUpdateOne, withGroupInvitationToken(git)) 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(git *GroupInvitationToken) *GroupInvitationTokenDeleteOne { return c.DeleteOneID(git.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(git *GroupInvitationToken) *GroupQuery { query := (&GroupClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := git.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(git.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...) } // Use 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} } // 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(i *Item) *ItemUpdateOne { mutation := newItemMutation(c.config, OpUpdateOne, withItem(i)) 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(i *Item) *ItemDeleteOne { return c.DeleteOneID(i.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 } // QueryParent queries the parent edge of a Item. func (c *ItemClient) QueryParent(i *Item) *ItemQuery { query := (&ItemClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := i.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(i.driver.Dialect(), step) return fromV, nil } return query } // QueryChildren queries the children edge of a Item. func (c *ItemClient) QueryChildren(i *Item) *ItemQuery { query := (&ItemClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := i.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(i.driver.Dialect(), step) return fromV, nil } return query } // QueryGroup queries the group edge of a Item. func (c *ItemClient) QueryGroup(i *Item) *GroupQuery { query := (&GroupClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := i.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(i.driver.Dialect(), step) return fromV, nil } return query } // QueryLabel queries the label edge of a Item. func (c *ItemClient) QueryLabel(i *Item) *LabelQuery { query := (&LabelClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := i.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(i.driver.Dialect(), step) return fromV, nil } return query } // QueryLocation queries the location edge of a Item. func (c *ItemClient) QueryLocation(i *Item) *LocationQuery { query := (&LocationClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := i.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(i.driver.Dialect(), step) return fromV, nil } return query } // QueryFields queries the fields edge of a Item. func (c *ItemClient) QueryFields(i *Item) *ItemFieldQuery { query := (&ItemFieldClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := i.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(i.driver.Dialect(), step) return fromV, nil } return query } // QueryMaintenanceEntries queries the maintenance_entries edge of a Item. func (c *ItemClient) QueryMaintenanceEntries(i *Item) *MaintenanceEntryQuery { query := (&MaintenanceEntryClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := i.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(i.driver.Dialect(), step) return fromV, nil } return query } // QueryAttachments queries the attachments edge of a Item. func (c *ItemClient) QueryAttachments(i *Item) *AttachmentQuery { query := (&AttachmentClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := i.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(i.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...) } // Use 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} } // 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(_if *ItemField) *ItemFieldUpdateOne { mutation := newItemFieldMutation(c.config, OpUpdateOne, withItemField(_if)) 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(_if *ItemField) *ItemFieldDeleteOne { return c.DeleteOneID(_if.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(_if *ItemField) *ItemQuery { query := (&ItemClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _if.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(_if.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()) } } // 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...) } // Use 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} } // 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(l *Label) *LabelUpdateOne { mutation := newLabelMutation(c.config, OpUpdateOne, withLabel(l)) 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(l *Label) *LabelDeleteOne { return c.DeleteOneID(l.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(l *Label) *GroupQuery { query := (&GroupClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := l.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(l.driver.Dialect(), step) return fromV, nil } return query } // QueryItems queries the items edge of a Label. func (c *LabelClient) QueryItems(l *Label) *ItemQuery { query := (&ItemClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := l.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(l.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...) } // Use 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} } // 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(l *Location) *LocationUpdateOne { mutation := newLocationMutation(c.config, OpUpdateOne, withLocation(l)) 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(l *Location) *LocationDeleteOne { return c.DeleteOneID(l.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 } // QueryParent queries the parent edge of a Location. func (c *LocationClient) QueryParent(l *Location) *LocationQuery { query := (&LocationClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := l.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(l.driver.Dialect(), step) return fromV, nil } return query } // QueryChildren queries the children edge of a Location. func (c *LocationClient) QueryChildren(l *Location) *LocationQuery { query := (&LocationClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := l.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(l.driver.Dialect(), step) return fromV, nil } return query } // QueryGroup queries the group edge of a Location. func (c *LocationClient) QueryGroup(l *Location) *GroupQuery { query := (&GroupClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := l.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(l.driver.Dialect(), step) return fromV, nil } return query } // QueryItems queries the items edge of a Location. func (c *LocationClient) QueryItems(l *Location) *ItemQuery { query := (&ItemClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := l.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(l.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...) } // Use 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} } // 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(me *MaintenanceEntry) *MaintenanceEntryUpdateOne { mutation := newMaintenanceEntryMutation(c.config, OpUpdateOne, withMaintenanceEntry(me)) 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(me *MaintenanceEntry) *MaintenanceEntryDeleteOne { return c.DeleteOneID(me.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(me *MaintenanceEntry) *ItemQuery { query := (&ItemClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := me.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(me.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()) } } // 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...) } // Use 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} } // 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(u *User) *UserUpdateOne { mutation := newUserMutation(c.config, OpUpdateOne, withUser(u)) 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(u *User) *UserDeleteOne { return c.DeleteOneID(u.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(u *User) *GroupQuery { query := (&GroupClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := u.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(u.driver.Dialect(), step) return fromV, nil } return query } // QueryAuthTokens queries the auth_tokens edge of a User. func (c *UserClient) QueryAuthTokens(u *User) *AuthTokensQuery { query := (&AuthTokensClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := u.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(u.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()) } }