1074 lines
		
	
	
		
			36 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			1074 lines
		
	
	
		
			36 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Code generated by ent, DO NOT EDIT.
 | |
| 
 | |
| package ent
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 	"errors"
 | |
| 	"fmt"
 | |
| 	"log"
 | |
| 	"reflect"
 | |
| 
 | |
| 	"code.icod.de/postfix/manager/ent/migrate"
 | |
| 
 | |
| 	"code.icod.de/postfix/manager/ent/account"
 | |
| 	"code.icod.de/postfix/manager/ent/alias"
 | |
| 	"code.icod.de/postfix/manager/ent/domain"
 | |
| 	"code.icod.de/postfix/manager/ent/logentry"
 | |
| 	"code.icod.de/postfix/manager/ent/mailbox"
 | |
| 	"entgo.io/ent"
 | |
| 	"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
 | |
| 	// Account is the client for interacting with the Account builders.
 | |
| 	Account *AccountClient
 | |
| 	// Alias is the client for interacting with the Alias builders.
 | |
| 	Alias *AliasClient
 | |
| 	// Domain is the client for interacting with the Domain builders.
 | |
| 	Domain *DomainClient
 | |
| 	// Logentry is the client for interacting with the Logentry builders.
 | |
| 	Logentry *LogentryClient
 | |
| 	// Mailbox is the client for interacting with the Mailbox builders.
 | |
| 	Mailbox *MailboxClient
 | |
| }
 | |
| 
 | |
| // 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.Account = NewAccountClient(c.config)
 | |
| 	c.Alias = NewAliasClient(c.config)
 | |
| 	c.Domain = NewDomainClient(c.config)
 | |
| 	c.Logentry = NewLogentryClient(c.config)
 | |
| 	c.Mailbox = NewMailboxClient(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,
 | |
| 		Account:  NewAccountClient(cfg),
 | |
| 		Alias:    NewAliasClient(cfg),
 | |
| 		Domain:   NewDomainClient(cfg),
 | |
| 		Logentry: NewLogentryClient(cfg),
 | |
| 		Mailbox:  NewMailboxClient(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,
 | |
| 		Account:  NewAccountClient(cfg),
 | |
| 		Alias:    NewAliasClient(cfg),
 | |
| 		Domain:   NewDomainClient(cfg),
 | |
| 		Logentry: NewLogentryClient(cfg),
 | |
| 		Mailbox:  NewMailboxClient(cfg),
 | |
| 	}, nil
 | |
| }
 | |
| 
 | |
| // Debug returns a new debug-client. It's used to get verbose logging on specific operations.
 | |
| //
 | |
| //	client.Debug().
 | |
| //		Account.
 | |
| //		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.Account.Use(hooks...)
 | |
| 	c.Alias.Use(hooks...)
 | |
| 	c.Domain.Use(hooks...)
 | |
| 	c.Logentry.Use(hooks...)
 | |
| 	c.Mailbox.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.Account.Intercept(interceptors...)
 | |
| 	c.Alias.Intercept(interceptors...)
 | |
| 	c.Domain.Intercept(interceptors...)
 | |
| 	c.Logentry.Intercept(interceptors...)
 | |
| 	c.Mailbox.Intercept(interceptors...)
 | |
| }
 | |
| 
 | |
| // Mutate implements the ent.Mutator interface.
 | |
| func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
 | |
| 	switch m := m.(type) {
 | |
| 	case *AccountMutation:
 | |
| 		return c.Account.mutate(ctx, m)
 | |
| 	case *AliasMutation:
 | |
| 		return c.Alias.mutate(ctx, m)
 | |
| 	case *DomainMutation:
 | |
| 		return c.Domain.mutate(ctx, m)
 | |
| 	case *LogentryMutation:
 | |
| 		return c.Logentry.mutate(ctx, m)
 | |
| 	case *MailboxMutation:
 | |
| 		return c.Mailbox.mutate(ctx, m)
 | |
| 	default:
 | |
| 		return nil, fmt.Errorf("ent: unknown mutation type %T", m)
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // AccountClient is a client for the Account schema.
 | |
| type AccountClient struct {
 | |
| 	config
 | |
| }
 | |
| 
 | |
| // NewAccountClient returns a client for the Account from the given config.
 | |
| func NewAccountClient(c config) *AccountClient {
 | |
| 	return &AccountClient{config: c}
 | |
| }
 | |
| 
 | |
| // Use adds a list of mutation hooks to the hooks stack.
 | |
| // A call to `Use(f, g, h)` equals to `account.Hooks(f(g(h())))`.
 | |
| func (c *AccountClient) Use(hooks ...Hook) {
 | |
| 	c.hooks.Account = append(c.hooks.Account, hooks...)
 | |
| }
 | |
| 
 | |
| // Intercept adds a list of query interceptors to the interceptors stack.
 | |
| // A call to `Intercept(f, g, h)` equals to `account.Intercept(f(g(h())))`.
 | |
| func (c *AccountClient) Intercept(interceptors ...Interceptor) {
 | |
| 	c.inters.Account = append(c.inters.Account, interceptors...)
 | |
| }
 | |
| 
 | |
| // Create returns a builder for creating a Account entity.
 | |
| func (c *AccountClient) Create() *AccountCreate {
 | |
| 	mutation := newAccountMutation(c.config, OpCreate)
 | |
| 	return &AccountCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // CreateBulk returns a builder for creating a bulk of Account entities.
 | |
| func (c *AccountClient) CreateBulk(builders ...*AccountCreate) *AccountCreateBulk {
 | |
| 	return &AccountCreateBulk{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 *AccountClient) MapCreateBulk(slice any, setFunc func(*AccountCreate, int)) *AccountCreateBulk {
 | |
| 	rv := reflect.ValueOf(slice)
 | |
| 	if rv.Kind() != reflect.Slice {
 | |
| 		return &AccountCreateBulk{err: fmt.Errorf("calling to AccountClient.MapCreateBulk with wrong type %T, need slice", slice)}
 | |
| 	}
 | |
| 	builders := make([]*AccountCreate, rv.Len())
 | |
| 	for i := 0; i < rv.Len(); i++ {
 | |
| 		builders[i] = c.Create()
 | |
| 		setFunc(builders[i], i)
 | |
| 	}
 | |
| 	return &AccountCreateBulk{config: c.config, builders: builders}
 | |
| }
 | |
| 
 | |
| // Update returns an update builder for Account.
 | |
| func (c *AccountClient) Update() *AccountUpdate {
 | |
| 	mutation := newAccountMutation(c.config, OpUpdate)
 | |
| 	return &AccountUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // UpdateOne returns an update builder for the given entity.
 | |
| func (c *AccountClient) UpdateOne(a *Account) *AccountUpdateOne {
 | |
| 	mutation := newAccountMutation(c.config, OpUpdateOne, withAccount(a))
 | |
| 	return &AccountUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // UpdateOneID returns an update builder for the given id.
 | |
| func (c *AccountClient) UpdateOneID(id int64) *AccountUpdateOne {
 | |
| 	mutation := newAccountMutation(c.config, OpUpdateOne, withAccountID(id))
 | |
| 	return &AccountUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // Delete returns a delete builder for Account.
 | |
| func (c *AccountClient) Delete() *AccountDelete {
 | |
| 	mutation := newAccountMutation(c.config, OpDelete)
 | |
| 	return &AccountDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // DeleteOne returns a builder for deleting the given entity.
 | |
| func (c *AccountClient) DeleteOne(a *Account) *AccountDeleteOne {
 | |
| 	return c.DeleteOneID(a.ID)
 | |
| }
 | |
| 
 | |
| // DeleteOneID returns a builder for deleting the given entity by its id.
 | |
| func (c *AccountClient) DeleteOneID(id int64) *AccountDeleteOne {
 | |
| 	builder := c.Delete().Where(account.ID(id))
 | |
| 	builder.mutation.id = &id
 | |
| 	builder.mutation.op = OpDeleteOne
 | |
| 	return &AccountDeleteOne{builder}
 | |
| }
 | |
| 
 | |
| // Query returns a query builder for Account.
 | |
| func (c *AccountClient) Query() *AccountQuery {
 | |
| 	return &AccountQuery{
 | |
| 		config: c.config,
 | |
| 		ctx:    &QueryContext{Type: TypeAccount},
 | |
| 		inters: c.Interceptors(),
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // Get returns a Account entity by its id.
 | |
| func (c *AccountClient) Get(ctx context.Context, id int64) (*Account, error) {
 | |
| 	return c.Query().Where(account.ID(id)).Only(ctx)
 | |
| }
 | |
| 
 | |
| // GetX is like Get, but panics if an error occurs.
 | |
| func (c *AccountClient) GetX(ctx context.Context, id int64) *Account {
 | |
| 	obj, err := c.Get(ctx, id)
 | |
| 	if err != nil {
 | |
| 		panic(err)
 | |
| 	}
 | |
| 	return obj
 | |
| }
 | |
| 
 | |
| // QueryDomains queries the domains edge of a Account.
 | |
| func (c *AccountClient) QueryDomains(a *Account) *DomainQuery {
 | |
| 	query := (&DomainClient{config: c.config}).Query()
 | |
| 	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
 | |
| 		id := a.ID
 | |
| 		step := sqlgraph.NewStep(
 | |
| 			sqlgraph.From(account.Table, account.FieldID, id),
 | |
| 			sqlgraph.To(domain.Table, domain.FieldID),
 | |
| 			sqlgraph.Edge(sqlgraph.M2M, false, account.DomainsTable, account.DomainsPrimaryKey...),
 | |
| 		)
 | |
| 		fromV = sqlgraph.Neighbors(a.driver.Dialect(), step)
 | |
| 		return fromV, nil
 | |
| 	}
 | |
| 	return query
 | |
| }
 | |
| 
 | |
| // QueryLogs queries the logs edge of a Account.
 | |
| func (c *AccountClient) QueryLogs(a *Account) *LogentryQuery {
 | |
| 	query := (&LogentryClient{config: c.config}).Query()
 | |
| 	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
 | |
| 		id := a.ID
 | |
| 		step := sqlgraph.NewStep(
 | |
| 			sqlgraph.From(account.Table, account.FieldID, id),
 | |
| 			sqlgraph.To(logentry.Table, logentry.FieldID),
 | |
| 			sqlgraph.Edge(sqlgraph.O2M, false, account.LogsTable, account.LogsColumn),
 | |
| 		)
 | |
| 		fromV = sqlgraph.Neighbors(a.driver.Dialect(), step)
 | |
| 		return fromV, nil
 | |
| 	}
 | |
| 	return query
 | |
| }
 | |
| 
 | |
| // Hooks returns the client hooks.
 | |
| func (c *AccountClient) Hooks() []Hook {
 | |
| 	return c.hooks.Account
 | |
| }
 | |
| 
 | |
| // Interceptors returns the client interceptors.
 | |
| func (c *AccountClient) Interceptors() []Interceptor {
 | |
| 	return c.inters.Account
 | |
| }
 | |
| 
 | |
| func (c *AccountClient) mutate(ctx context.Context, m *AccountMutation) (Value, error) {
 | |
| 	switch m.Op() {
 | |
| 	case OpCreate:
 | |
| 		return (&AccountCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
 | |
| 	case OpUpdate:
 | |
| 		return (&AccountUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
 | |
| 	case OpUpdateOne:
 | |
| 		return (&AccountUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
 | |
| 	case OpDelete, OpDeleteOne:
 | |
| 		return (&AccountDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
 | |
| 	default:
 | |
| 		return nil, fmt.Errorf("ent: unknown Account mutation op: %q", m.Op())
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // AliasClient is a client for the Alias schema.
 | |
| type AliasClient struct {
 | |
| 	config
 | |
| }
 | |
| 
 | |
| // NewAliasClient returns a client for the Alias from the given config.
 | |
| func NewAliasClient(c config) *AliasClient {
 | |
| 	return &AliasClient{config: c}
 | |
| }
 | |
| 
 | |
| // Use adds a list of mutation hooks to the hooks stack.
 | |
| // A call to `Use(f, g, h)` equals to `alias.Hooks(f(g(h())))`.
 | |
| func (c *AliasClient) Use(hooks ...Hook) {
 | |
| 	c.hooks.Alias = append(c.hooks.Alias, hooks...)
 | |
| }
 | |
| 
 | |
| // Intercept adds a list of query interceptors to the interceptors stack.
 | |
| // A call to `Intercept(f, g, h)` equals to `alias.Intercept(f(g(h())))`.
 | |
| func (c *AliasClient) Intercept(interceptors ...Interceptor) {
 | |
| 	c.inters.Alias = append(c.inters.Alias, interceptors...)
 | |
| }
 | |
| 
 | |
| // Create returns a builder for creating a Alias entity.
 | |
| func (c *AliasClient) Create() *AliasCreate {
 | |
| 	mutation := newAliasMutation(c.config, OpCreate)
 | |
| 	return &AliasCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // CreateBulk returns a builder for creating a bulk of Alias entities.
 | |
| func (c *AliasClient) CreateBulk(builders ...*AliasCreate) *AliasCreateBulk {
 | |
| 	return &AliasCreateBulk{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 *AliasClient) MapCreateBulk(slice any, setFunc func(*AliasCreate, int)) *AliasCreateBulk {
 | |
| 	rv := reflect.ValueOf(slice)
 | |
| 	if rv.Kind() != reflect.Slice {
 | |
| 		return &AliasCreateBulk{err: fmt.Errorf("calling to AliasClient.MapCreateBulk with wrong type %T, need slice", slice)}
 | |
| 	}
 | |
| 	builders := make([]*AliasCreate, rv.Len())
 | |
| 	for i := 0; i < rv.Len(); i++ {
 | |
| 		builders[i] = c.Create()
 | |
| 		setFunc(builders[i], i)
 | |
| 	}
 | |
| 	return &AliasCreateBulk{config: c.config, builders: builders}
 | |
| }
 | |
| 
 | |
| // Update returns an update builder for Alias.
 | |
| func (c *AliasClient) Update() *AliasUpdate {
 | |
| 	mutation := newAliasMutation(c.config, OpUpdate)
 | |
| 	return &AliasUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // UpdateOne returns an update builder for the given entity.
 | |
| func (c *AliasClient) UpdateOne(a *Alias) *AliasUpdateOne {
 | |
| 	mutation := newAliasMutation(c.config, OpUpdateOne, withAlias(a))
 | |
| 	return &AliasUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // UpdateOneID returns an update builder for the given id.
 | |
| func (c *AliasClient) UpdateOneID(id int64) *AliasUpdateOne {
 | |
| 	mutation := newAliasMutation(c.config, OpUpdateOne, withAliasID(id))
 | |
| 	return &AliasUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // Delete returns a delete builder for Alias.
 | |
| func (c *AliasClient) Delete() *AliasDelete {
 | |
| 	mutation := newAliasMutation(c.config, OpDelete)
 | |
| 	return &AliasDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // DeleteOne returns a builder for deleting the given entity.
 | |
| func (c *AliasClient) DeleteOne(a *Alias) *AliasDeleteOne {
 | |
| 	return c.DeleteOneID(a.ID)
 | |
| }
 | |
| 
 | |
| // DeleteOneID returns a builder for deleting the given entity by its id.
 | |
| func (c *AliasClient) DeleteOneID(id int64) *AliasDeleteOne {
 | |
| 	builder := c.Delete().Where(alias.ID(id))
 | |
| 	builder.mutation.id = &id
 | |
| 	builder.mutation.op = OpDeleteOne
 | |
| 	return &AliasDeleteOne{builder}
 | |
| }
 | |
| 
 | |
| // Query returns a query builder for Alias.
 | |
| func (c *AliasClient) Query() *AliasQuery {
 | |
| 	return &AliasQuery{
 | |
| 		config: c.config,
 | |
| 		ctx:    &QueryContext{Type: TypeAlias},
 | |
| 		inters: c.Interceptors(),
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // Get returns a Alias entity by its id.
 | |
| func (c *AliasClient) Get(ctx context.Context, id int64) (*Alias, error) {
 | |
| 	return c.Query().Where(alias.ID(id)).Only(ctx)
 | |
| }
 | |
| 
 | |
| // GetX is like Get, but panics if an error occurs.
 | |
| func (c *AliasClient) GetX(ctx context.Context, id int64) *Alias {
 | |
| 	obj, err := c.Get(ctx, id)
 | |
| 	if err != nil {
 | |
| 		panic(err)
 | |
| 	}
 | |
| 	return obj
 | |
| }
 | |
| 
 | |
| // QueryDomain queries the domain edge of a Alias.
 | |
| func (c *AliasClient) QueryDomain(a *Alias) *DomainQuery {
 | |
| 	query := (&DomainClient{config: c.config}).Query()
 | |
| 	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
 | |
| 		id := a.ID
 | |
| 		step := sqlgraph.NewStep(
 | |
| 			sqlgraph.From(alias.Table, alias.FieldID, id),
 | |
| 			sqlgraph.To(domain.Table, domain.FieldID),
 | |
| 			sqlgraph.Edge(sqlgraph.M2O, true, alias.DomainTable, alias.DomainColumn),
 | |
| 		)
 | |
| 		fromV = sqlgraph.Neighbors(a.driver.Dialect(), step)
 | |
| 		return fromV, nil
 | |
| 	}
 | |
| 	return query
 | |
| }
 | |
| 
 | |
| // Hooks returns the client hooks.
 | |
| func (c *AliasClient) Hooks() []Hook {
 | |
| 	return c.hooks.Alias
 | |
| }
 | |
| 
 | |
| // Interceptors returns the client interceptors.
 | |
| func (c *AliasClient) Interceptors() []Interceptor {
 | |
| 	return c.inters.Alias
 | |
| }
 | |
| 
 | |
| func (c *AliasClient) mutate(ctx context.Context, m *AliasMutation) (Value, error) {
 | |
| 	switch m.Op() {
 | |
| 	case OpCreate:
 | |
| 		return (&AliasCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
 | |
| 	case OpUpdate:
 | |
| 		return (&AliasUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
 | |
| 	case OpUpdateOne:
 | |
| 		return (&AliasUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
 | |
| 	case OpDelete, OpDeleteOne:
 | |
| 		return (&AliasDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
 | |
| 	default:
 | |
| 		return nil, fmt.Errorf("ent: unknown Alias mutation op: %q", m.Op())
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // DomainClient is a client for the Domain schema.
 | |
| type DomainClient struct {
 | |
| 	config
 | |
| }
 | |
| 
 | |
| // NewDomainClient returns a client for the Domain from the given config.
 | |
| func NewDomainClient(c config) *DomainClient {
 | |
| 	return &DomainClient{config: c}
 | |
| }
 | |
| 
 | |
| // Use adds a list of mutation hooks to the hooks stack.
 | |
| // A call to `Use(f, g, h)` equals to `domain.Hooks(f(g(h())))`.
 | |
| func (c *DomainClient) Use(hooks ...Hook) {
 | |
| 	c.hooks.Domain = append(c.hooks.Domain, hooks...)
 | |
| }
 | |
| 
 | |
| // Intercept adds a list of query interceptors to the interceptors stack.
 | |
| // A call to `Intercept(f, g, h)` equals to `domain.Intercept(f(g(h())))`.
 | |
| func (c *DomainClient) Intercept(interceptors ...Interceptor) {
 | |
| 	c.inters.Domain = append(c.inters.Domain, interceptors...)
 | |
| }
 | |
| 
 | |
| // Create returns a builder for creating a Domain entity.
 | |
| func (c *DomainClient) Create() *DomainCreate {
 | |
| 	mutation := newDomainMutation(c.config, OpCreate)
 | |
| 	return &DomainCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // CreateBulk returns a builder for creating a bulk of Domain entities.
 | |
| func (c *DomainClient) CreateBulk(builders ...*DomainCreate) *DomainCreateBulk {
 | |
| 	return &DomainCreateBulk{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 *DomainClient) MapCreateBulk(slice any, setFunc func(*DomainCreate, int)) *DomainCreateBulk {
 | |
| 	rv := reflect.ValueOf(slice)
 | |
| 	if rv.Kind() != reflect.Slice {
 | |
| 		return &DomainCreateBulk{err: fmt.Errorf("calling to DomainClient.MapCreateBulk with wrong type %T, need slice", slice)}
 | |
| 	}
 | |
| 	builders := make([]*DomainCreate, rv.Len())
 | |
| 	for i := 0; i < rv.Len(); i++ {
 | |
| 		builders[i] = c.Create()
 | |
| 		setFunc(builders[i], i)
 | |
| 	}
 | |
| 	return &DomainCreateBulk{config: c.config, builders: builders}
 | |
| }
 | |
| 
 | |
| // Update returns an update builder for Domain.
 | |
| func (c *DomainClient) Update() *DomainUpdate {
 | |
| 	mutation := newDomainMutation(c.config, OpUpdate)
 | |
| 	return &DomainUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // UpdateOne returns an update builder for the given entity.
 | |
| func (c *DomainClient) UpdateOne(d *Domain) *DomainUpdateOne {
 | |
| 	mutation := newDomainMutation(c.config, OpUpdateOne, withDomain(d))
 | |
| 	return &DomainUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // UpdateOneID returns an update builder for the given id.
 | |
| func (c *DomainClient) UpdateOneID(id int64) *DomainUpdateOne {
 | |
| 	mutation := newDomainMutation(c.config, OpUpdateOne, withDomainID(id))
 | |
| 	return &DomainUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // Delete returns a delete builder for Domain.
 | |
| func (c *DomainClient) Delete() *DomainDelete {
 | |
| 	mutation := newDomainMutation(c.config, OpDelete)
 | |
| 	return &DomainDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // DeleteOne returns a builder for deleting the given entity.
 | |
| func (c *DomainClient) DeleteOne(d *Domain) *DomainDeleteOne {
 | |
| 	return c.DeleteOneID(d.ID)
 | |
| }
 | |
| 
 | |
| // DeleteOneID returns a builder for deleting the given entity by its id.
 | |
| func (c *DomainClient) DeleteOneID(id int64) *DomainDeleteOne {
 | |
| 	builder := c.Delete().Where(domain.ID(id))
 | |
| 	builder.mutation.id = &id
 | |
| 	builder.mutation.op = OpDeleteOne
 | |
| 	return &DomainDeleteOne{builder}
 | |
| }
 | |
| 
 | |
| // Query returns a query builder for Domain.
 | |
| func (c *DomainClient) Query() *DomainQuery {
 | |
| 	return &DomainQuery{
 | |
| 		config: c.config,
 | |
| 		ctx:    &QueryContext{Type: TypeDomain},
 | |
| 		inters: c.Interceptors(),
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // Get returns a Domain entity by its id.
 | |
| func (c *DomainClient) Get(ctx context.Context, id int64) (*Domain, error) {
 | |
| 	return c.Query().Where(domain.ID(id)).Only(ctx)
 | |
| }
 | |
| 
 | |
| // GetX is like Get, but panics if an error occurs.
 | |
| func (c *DomainClient) GetX(ctx context.Context, id int64) *Domain {
 | |
| 	obj, err := c.Get(ctx, id)
 | |
| 	if err != nil {
 | |
| 		panic(err)
 | |
| 	}
 | |
| 	return obj
 | |
| }
 | |
| 
 | |
| // QueryMailboxes queries the mailboxes edge of a Domain.
 | |
| func (c *DomainClient) QueryMailboxes(d *Domain) *MailboxQuery {
 | |
| 	query := (&MailboxClient{config: c.config}).Query()
 | |
| 	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
 | |
| 		id := d.ID
 | |
| 		step := sqlgraph.NewStep(
 | |
| 			sqlgraph.From(domain.Table, domain.FieldID, id),
 | |
| 			sqlgraph.To(mailbox.Table, mailbox.FieldID),
 | |
| 			sqlgraph.Edge(sqlgraph.O2M, false, domain.MailboxesTable, domain.MailboxesColumn),
 | |
| 		)
 | |
| 		fromV = sqlgraph.Neighbors(d.driver.Dialect(), step)
 | |
| 		return fromV, nil
 | |
| 	}
 | |
| 	return query
 | |
| }
 | |
| 
 | |
| // QueryAliases queries the aliases edge of a Domain.
 | |
| func (c *DomainClient) QueryAliases(d *Domain) *AliasQuery {
 | |
| 	query := (&AliasClient{config: c.config}).Query()
 | |
| 	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
 | |
| 		id := d.ID
 | |
| 		step := sqlgraph.NewStep(
 | |
| 			sqlgraph.From(domain.Table, domain.FieldID, id),
 | |
| 			sqlgraph.To(alias.Table, alias.FieldID),
 | |
| 			sqlgraph.Edge(sqlgraph.O2M, false, domain.AliasesTable, domain.AliasesColumn),
 | |
| 		)
 | |
| 		fromV = sqlgraph.Neighbors(d.driver.Dialect(), step)
 | |
| 		return fromV, nil
 | |
| 	}
 | |
| 	return query
 | |
| }
 | |
| 
 | |
| // QueryLogs queries the logs edge of a Domain.
 | |
| func (c *DomainClient) QueryLogs(d *Domain) *LogentryQuery {
 | |
| 	query := (&LogentryClient{config: c.config}).Query()
 | |
| 	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
 | |
| 		id := d.ID
 | |
| 		step := sqlgraph.NewStep(
 | |
| 			sqlgraph.From(domain.Table, domain.FieldID, id),
 | |
| 			sqlgraph.To(logentry.Table, logentry.FieldID),
 | |
| 			sqlgraph.Edge(sqlgraph.O2M, false, domain.LogsTable, domain.LogsColumn),
 | |
| 		)
 | |
| 		fromV = sqlgraph.Neighbors(d.driver.Dialect(), step)
 | |
| 		return fromV, nil
 | |
| 	}
 | |
| 	return query
 | |
| }
 | |
| 
 | |
| // QueryAccounts queries the accounts edge of a Domain.
 | |
| func (c *DomainClient) QueryAccounts(d *Domain) *AccountQuery {
 | |
| 	query := (&AccountClient{config: c.config}).Query()
 | |
| 	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
 | |
| 		id := d.ID
 | |
| 		step := sqlgraph.NewStep(
 | |
| 			sqlgraph.From(domain.Table, domain.FieldID, id),
 | |
| 			sqlgraph.To(account.Table, account.FieldID),
 | |
| 			sqlgraph.Edge(sqlgraph.M2M, true, domain.AccountsTable, domain.AccountsPrimaryKey...),
 | |
| 		)
 | |
| 		fromV = sqlgraph.Neighbors(d.driver.Dialect(), step)
 | |
| 		return fromV, nil
 | |
| 	}
 | |
| 	return query
 | |
| }
 | |
| 
 | |
| // Hooks returns the client hooks.
 | |
| func (c *DomainClient) Hooks() []Hook {
 | |
| 	return c.hooks.Domain
 | |
| }
 | |
| 
 | |
| // Interceptors returns the client interceptors.
 | |
| func (c *DomainClient) Interceptors() []Interceptor {
 | |
| 	return c.inters.Domain
 | |
| }
 | |
| 
 | |
| func (c *DomainClient) mutate(ctx context.Context, m *DomainMutation) (Value, error) {
 | |
| 	switch m.Op() {
 | |
| 	case OpCreate:
 | |
| 		return (&DomainCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
 | |
| 	case OpUpdate:
 | |
| 		return (&DomainUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
 | |
| 	case OpUpdateOne:
 | |
| 		return (&DomainUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
 | |
| 	case OpDelete, OpDeleteOne:
 | |
| 		return (&DomainDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
 | |
| 	default:
 | |
| 		return nil, fmt.Errorf("ent: unknown Domain mutation op: %q", m.Op())
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // LogentryClient is a client for the Logentry schema.
 | |
| type LogentryClient struct {
 | |
| 	config
 | |
| }
 | |
| 
 | |
| // NewLogentryClient returns a client for the Logentry from the given config.
 | |
| func NewLogentryClient(c config) *LogentryClient {
 | |
| 	return &LogentryClient{config: c}
 | |
| }
 | |
| 
 | |
| // Use adds a list of mutation hooks to the hooks stack.
 | |
| // A call to `Use(f, g, h)` equals to `logentry.Hooks(f(g(h())))`.
 | |
| func (c *LogentryClient) Use(hooks ...Hook) {
 | |
| 	c.hooks.Logentry = append(c.hooks.Logentry, hooks...)
 | |
| }
 | |
| 
 | |
| // Intercept adds a list of query interceptors to the interceptors stack.
 | |
| // A call to `Intercept(f, g, h)` equals to `logentry.Intercept(f(g(h())))`.
 | |
| func (c *LogentryClient) Intercept(interceptors ...Interceptor) {
 | |
| 	c.inters.Logentry = append(c.inters.Logentry, interceptors...)
 | |
| }
 | |
| 
 | |
| // Create returns a builder for creating a Logentry entity.
 | |
| func (c *LogentryClient) Create() *LogentryCreate {
 | |
| 	mutation := newLogentryMutation(c.config, OpCreate)
 | |
| 	return &LogentryCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // CreateBulk returns a builder for creating a bulk of Logentry entities.
 | |
| func (c *LogentryClient) CreateBulk(builders ...*LogentryCreate) *LogentryCreateBulk {
 | |
| 	return &LogentryCreateBulk{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 *LogentryClient) MapCreateBulk(slice any, setFunc func(*LogentryCreate, int)) *LogentryCreateBulk {
 | |
| 	rv := reflect.ValueOf(slice)
 | |
| 	if rv.Kind() != reflect.Slice {
 | |
| 		return &LogentryCreateBulk{err: fmt.Errorf("calling to LogentryClient.MapCreateBulk with wrong type %T, need slice", slice)}
 | |
| 	}
 | |
| 	builders := make([]*LogentryCreate, rv.Len())
 | |
| 	for i := 0; i < rv.Len(); i++ {
 | |
| 		builders[i] = c.Create()
 | |
| 		setFunc(builders[i], i)
 | |
| 	}
 | |
| 	return &LogentryCreateBulk{config: c.config, builders: builders}
 | |
| }
 | |
| 
 | |
| // Update returns an update builder for Logentry.
 | |
| func (c *LogentryClient) Update() *LogentryUpdate {
 | |
| 	mutation := newLogentryMutation(c.config, OpUpdate)
 | |
| 	return &LogentryUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // UpdateOne returns an update builder for the given entity.
 | |
| func (c *LogentryClient) UpdateOne(l *Logentry) *LogentryUpdateOne {
 | |
| 	mutation := newLogentryMutation(c.config, OpUpdateOne, withLogentry(l))
 | |
| 	return &LogentryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // UpdateOneID returns an update builder for the given id.
 | |
| func (c *LogentryClient) UpdateOneID(id int64) *LogentryUpdateOne {
 | |
| 	mutation := newLogentryMutation(c.config, OpUpdateOne, withLogentryID(id))
 | |
| 	return &LogentryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // Delete returns a delete builder for Logentry.
 | |
| func (c *LogentryClient) Delete() *LogentryDelete {
 | |
| 	mutation := newLogentryMutation(c.config, OpDelete)
 | |
| 	return &LogentryDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // DeleteOne returns a builder for deleting the given entity.
 | |
| func (c *LogentryClient) DeleteOne(l *Logentry) *LogentryDeleteOne {
 | |
| 	return c.DeleteOneID(l.ID)
 | |
| }
 | |
| 
 | |
| // DeleteOneID returns a builder for deleting the given entity by its id.
 | |
| func (c *LogentryClient) DeleteOneID(id int64) *LogentryDeleteOne {
 | |
| 	builder := c.Delete().Where(logentry.ID(id))
 | |
| 	builder.mutation.id = &id
 | |
| 	builder.mutation.op = OpDeleteOne
 | |
| 	return &LogentryDeleteOne{builder}
 | |
| }
 | |
| 
 | |
| // Query returns a query builder for Logentry.
 | |
| func (c *LogentryClient) Query() *LogentryQuery {
 | |
| 	return &LogentryQuery{
 | |
| 		config: c.config,
 | |
| 		ctx:    &QueryContext{Type: TypeLogentry},
 | |
| 		inters: c.Interceptors(),
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // Get returns a Logentry entity by its id.
 | |
| func (c *LogentryClient) Get(ctx context.Context, id int64) (*Logentry, error) {
 | |
| 	return c.Query().Where(logentry.ID(id)).Only(ctx)
 | |
| }
 | |
| 
 | |
| // GetX is like Get, but panics if an error occurs.
 | |
| func (c *LogentryClient) GetX(ctx context.Context, id int64) *Logentry {
 | |
| 	obj, err := c.Get(ctx, id)
 | |
| 	if err != nil {
 | |
| 		panic(err)
 | |
| 	}
 | |
| 	return obj
 | |
| }
 | |
| 
 | |
| // QueryAccount queries the account edge of a Logentry.
 | |
| func (c *LogentryClient) QueryAccount(l *Logentry) *AccountQuery {
 | |
| 	query := (&AccountClient{config: c.config}).Query()
 | |
| 	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
 | |
| 		id := l.ID
 | |
| 		step := sqlgraph.NewStep(
 | |
| 			sqlgraph.From(logentry.Table, logentry.FieldID, id),
 | |
| 			sqlgraph.To(account.Table, account.FieldID),
 | |
| 			sqlgraph.Edge(sqlgraph.M2O, true, logentry.AccountTable, logentry.AccountColumn),
 | |
| 		)
 | |
| 		fromV = sqlgraph.Neighbors(l.driver.Dialect(), step)
 | |
| 		return fromV, nil
 | |
| 	}
 | |
| 	return query
 | |
| }
 | |
| 
 | |
| // QueryDomain queries the domain edge of a Logentry.
 | |
| func (c *LogentryClient) QueryDomain(l *Logentry) *DomainQuery {
 | |
| 	query := (&DomainClient{config: c.config}).Query()
 | |
| 	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
 | |
| 		id := l.ID
 | |
| 		step := sqlgraph.NewStep(
 | |
| 			sqlgraph.From(logentry.Table, logentry.FieldID, id),
 | |
| 			sqlgraph.To(domain.Table, domain.FieldID),
 | |
| 			sqlgraph.Edge(sqlgraph.M2O, true, logentry.DomainTable, logentry.DomainColumn),
 | |
| 		)
 | |
| 		fromV = sqlgraph.Neighbors(l.driver.Dialect(), step)
 | |
| 		return fromV, nil
 | |
| 	}
 | |
| 	return query
 | |
| }
 | |
| 
 | |
| // Hooks returns the client hooks.
 | |
| func (c *LogentryClient) Hooks() []Hook {
 | |
| 	return c.hooks.Logentry
 | |
| }
 | |
| 
 | |
| // Interceptors returns the client interceptors.
 | |
| func (c *LogentryClient) Interceptors() []Interceptor {
 | |
| 	return c.inters.Logentry
 | |
| }
 | |
| 
 | |
| func (c *LogentryClient) mutate(ctx context.Context, m *LogentryMutation) (Value, error) {
 | |
| 	switch m.Op() {
 | |
| 	case OpCreate:
 | |
| 		return (&LogentryCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
 | |
| 	case OpUpdate:
 | |
| 		return (&LogentryUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
 | |
| 	case OpUpdateOne:
 | |
| 		return (&LogentryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
 | |
| 	case OpDelete, OpDeleteOne:
 | |
| 		return (&LogentryDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
 | |
| 	default:
 | |
| 		return nil, fmt.Errorf("ent: unknown Logentry mutation op: %q", m.Op())
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // MailboxClient is a client for the Mailbox schema.
 | |
| type MailboxClient struct {
 | |
| 	config
 | |
| }
 | |
| 
 | |
| // NewMailboxClient returns a client for the Mailbox from the given config.
 | |
| func NewMailboxClient(c config) *MailboxClient {
 | |
| 	return &MailboxClient{config: c}
 | |
| }
 | |
| 
 | |
| // Use adds a list of mutation hooks to the hooks stack.
 | |
| // A call to `Use(f, g, h)` equals to `mailbox.Hooks(f(g(h())))`.
 | |
| func (c *MailboxClient) Use(hooks ...Hook) {
 | |
| 	c.hooks.Mailbox = append(c.hooks.Mailbox, hooks...)
 | |
| }
 | |
| 
 | |
| // Intercept adds a list of query interceptors to the interceptors stack.
 | |
| // A call to `Intercept(f, g, h)` equals to `mailbox.Intercept(f(g(h())))`.
 | |
| func (c *MailboxClient) Intercept(interceptors ...Interceptor) {
 | |
| 	c.inters.Mailbox = append(c.inters.Mailbox, interceptors...)
 | |
| }
 | |
| 
 | |
| // Create returns a builder for creating a Mailbox entity.
 | |
| func (c *MailboxClient) Create() *MailboxCreate {
 | |
| 	mutation := newMailboxMutation(c.config, OpCreate)
 | |
| 	return &MailboxCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // CreateBulk returns a builder for creating a bulk of Mailbox entities.
 | |
| func (c *MailboxClient) CreateBulk(builders ...*MailboxCreate) *MailboxCreateBulk {
 | |
| 	return &MailboxCreateBulk{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 *MailboxClient) MapCreateBulk(slice any, setFunc func(*MailboxCreate, int)) *MailboxCreateBulk {
 | |
| 	rv := reflect.ValueOf(slice)
 | |
| 	if rv.Kind() != reflect.Slice {
 | |
| 		return &MailboxCreateBulk{err: fmt.Errorf("calling to MailboxClient.MapCreateBulk with wrong type %T, need slice", slice)}
 | |
| 	}
 | |
| 	builders := make([]*MailboxCreate, rv.Len())
 | |
| 	for i := 0; i < rv.Len(); i++ {
 | |
| 		builders[i] = c.Create()
 | |
| 		setFunc(builders[i], i)
 | |
| 	}
 | |
| 	return &MailboxCreateBulk{config: c.config, builders: builders}
 | |
| }
 | |
| 
 | |
| // Update returns an update builder for Mailbox.
 | |
| func (c *MailboxClient) Update() *MailboxUpdate {
 | |
| 	mutation := newMailboxMutation(c.config, OpUpdate)
 | |
| 	return &MailboxUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // UpdateOne returns an update builder for the given entity.
 | |
| func (c *MailboxClient) UpdateOne(m *Mailbox) *MailboxUpdateOne {
 | |
| 	mutation := newMailboxMutation(c.config, OpUpdateOne, withMailbox(m))
 | |
| 	return &MailboxUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // UpdateOneID returns an update builder for the given id.
 | |
| func (c *MailboxClient) UpdateOneID(id int64) *MailboxUpdateOne {
 | |
| 	mutation := newMailboxMutation(c.config, OpUpdateOne, withMailboxID(id))
 | |
| 	return &MailboxUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // Delete returns a delete builder for Mailbox.
 | |
| func (c *MailboxClient) Delete() *MailboxDelete {
 | |
| 	mutation := newMailboxMutation(c.config, OpDelete)
 | |
| 	return &MailboxDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
 | |
| }
 | |
| 
 | |
| // DeleteOne returns a builder for deleting the given entity.
 | |
| func (c *MailboxClient) DeleteOne(m *Mailbox) *MailboxDeleteOne {
 | |
| 	return c.DeleteOneID(m.ID)
 | |
| }
 | |
| 
 | |
| // DeleteOneID returns a builder for deleting the given entity by its id.
 | |
| func (c *MailboxClient) DeleteOneID(id int64) *MailboxDeleteOne {
 | |
| 	builder := c.Delete().Where(mailbox.ID(id))
 | |
| 	builder.mutation.id = &id
 | |
| 	builder.mutation.op = OpDeleteOne
 | |
| 	return &MailboxDeleteOne{builder}
 | |
| }
 | |
| 
 | |
| // Query returns a query builder for Mailbox.
 | |
| func (c *MailboxClient) Query() *MailboxQuery {
 | |
| 	return &MailboxQuery{
 | |
| 		config: c.config,
 | |
| 		ctx:    &QueryContext{Type: TypeMailbox},
 | |
| 		inters: c.Interceptors(),
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // Get returns a Mailbox entity by its id.
 | |
| func (c *MailboxClient) Get(ctx context.Context, id int64) (*Mailbox, error) {
 | |
| 	return c.Query().Where(mailbox.ID(id)).Only(ctx)
 | |
| }
 | |
| 
 | |
| // GetX is like Get, but panics if an error occurs.
 | |
| func (c *MailboxClient) GetX(ctx context.Context, id int64) *Mailbox {
 | |
| 	obj, err := c.Get(ctx, id)
 | |
| 	if err != nil {
 | |
| 		panic(err)
 | |
| 	}
 | |
| 	return obj
 | |
| }
 | |
| 
 | |
| // QueryDomain queries the domain edge of a Mailbox.
 | |
| func (c *MailboxClient) QueryDomain(m *Mailbox) *DomainQuery {
 | |
| 	query := (&DomainClient{config: c.config}).Query()
 | |
| 	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
 | |
| 		id := m.ID
 | |
| 		step := sqlgraph.NewStep(
 | |
| 			sqlgraph.From(mailbox.Table, mailbox.FieldID, id),
 | |
| 			sqlgraph.To(domain.Table, domain.FieldID),
 | |
| 			sqlgraph.Edge(sqlgraph.M2O, true, mailbox.DomainTable, mailbox.DomainColumn),
 | |
| 		)
 | |
| 		fromV = sqlgraph.Neighbors(m.driver.Dialect(), step)
 | |
| 		return fromV, nil
 | |
| 	}
 | |
| 	return query
 | |
| }
 | |
| 
 | |
| // Hooks returns the client hooks.
 | |
| func (c *MailboxClient) Hooks() []Hook {
 | |
| 	return c.hooks.Mailbox
 | |
| }
 | |
| 
 | |
| // Interceptors returns the client interceptors.
 | |
| func (c *MailboxClient) Interceptors() []Interceptor {
 | |
| 	return c.inters.Mailbox
 | |
| }
 | |
| 
 | |
| func (c *MailboxClient) mutate(ctx context.Context, m *MailboxMutation) (Value, error) {
 | |
| 	switch m.Op() {
 | |
| 	case OpCreate:
 | |
| 		return (&MailboxCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
 | |
| 	case OpUpdate:
 | |
| 		return (&MailboxUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
 | |
| 	case OpUpdateOne:
 | |
| 		return (&MailboxUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
 | |
| 	case OpDelete, OpDeleteOne:
 | |
| 		return (&MailboxDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
 | |
| 	default:
 | |
| 		return nil, fmt.Errorf("ent: unknown Mailbox mutation op: %q", m.Op())
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // hooks and interceptors per client, for fast access.
 | |
| type (
 | |
| 	hooks struct {
 | |
| 		Account, Alias, Domain, Logentry, Mailbox []ent.Hook
 | |
| 	}
 | |
| 	inters struct {
 | |
| 		Account, Alias, Domain, Logentry, Mailbox []ent.Interceptor
 | |
| 	}
 | |
| )
 |