// Code generated by ent, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "log" "somegit.dev/csgowtf/csgowtfd/ent/migrate" "entgo.io/ent" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "somegit.dev/csgowtf/csgowtfd/ent/match" "somegit.dev/csgowtf/csgowtfd/ent/matchplayer" "somegit.dev/csgowtf/csgowtfd/ent/messages" "somegit.dev/csgowtf/csgowtfd/ent/player" "somegit.dev/csgowtf/csgowtfd/ent/roundstats" "somegit.dev/csgowtf/csgowtfd/ent/spray" "somegit.dev/csgowtf/csgowtfd/ent/weapon" ) // 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 // Match is the client for interacting with the Match builders. Match *MatchClient // MatchPlayer is the client for interacting with the MatchPlayer builders. MatchPlayer *MatchPlayerClient // Messages is the client for interacting with the Messages builders. Messages *MessagesClient // Player is the client for interacting with the Player builders. Player *PlayerClient // RoundStats is the client for interacting with the RoundStats builders. RoundStats *RoundStatsClient // Spray is the client for interacting with the Spray builders. Spray *SprayClient // Weapon is the client for interacting with the Weapon builders. Weapon *WeaponClient } // 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.Match = NewMatchClient(c.config) c.MatchPlayer = NewMatchPlayerClient(c.config) c.Messages = NewMessagesClient(c.config) c.Player = NewPlayerClient(c.config) c.RoundStats = NewRoundStatsClient(c.config) c.Spray = NewSprayClient(c.config) c.Weapon = NewWeaponClient(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) ) // 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) } } // 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, Match: NewMatchClient(cfg), MatchPlayer: NewMatchPlayerClient(cfg), Messages: NewMessagesClient(cfg), Player: NewPlayerClient(cfg), RoundStats: NewRoundStatsClient(cfg), Spray: NewSprayClient(cfg), Weapon: NewWeaponClient(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, Match: NewMatchClient(cfg), MatchPlayer: NewMatchPlayerClient(cfg), Messages: NewMessagesClient(cfg), Player: NewPlayerClient(cfg), RoundStats: NewRoundStatsClient(cfg), Spray: NewSprayClient(cfg), Weapon: NewWeaponClient(cfg), }, nil } // Debug returns a new debug-client. It's used to get verbose logging on specific operations. // // client.Debug(). // Match. // Query(). // Count(ctx) func (c *Client) Debug() *Client { if c.debug { return c } cfg := c.config cfg.driver = dialect.Debug(c.driver, c.log) client := &Client{config: cfg} client.init() return client } // Close closes the database connection and prevents new queries from starting. func (c *Client) Close() error { return c.driver.Close() } // Use adds the mutation hooks to all the entity clients. // In order to add hooks to a specific client, call: `client.Node.Use(...)`. func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ c.Match, c.MatchPlayer, c.Messages, c.Player, c.RoundStats, c.Spray, c.Weapon, } { n.Use(hooks...) } } // Intercept adds the query interceptors to all the entity clients. // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ c.Match, c.MatchPlayer, c.Messages, c.Player, c.RoundStats, c.Spray, c.Weapon, } { n.Intercept(interceptors...) } } // Mutate implements the ent.Mutator interface. func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { switch m := m.(type) { case *MatchMutation: return c.Match.mutate(ctx, m) case *MatchPlayerMutation: return c.MatchPlayer.mutate(ctx, m) case *MessagesMutation: return c.Messages.mutate(ctx, m) case *PlayerMutation: return c.Player.mutate(ctx, m) case *RoundStatsMutation: return c.RoundStats.mutate(ctx, m) case *SprayMutation: return c.Spray.mutate(ctx, m) case *WeaponMutation: return c.Weapon.mutate(ctx, m) default: return nil, fmt.Errorf("ent: unknown mutation type %T", m) } } // MatchClient is a client for the Match schema. type MatchClient struct { config } // NewMatchClient returns a client for the Match from the given config. func NewMatchClient(c config) *MatchClient { return &MatchClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `match.Hooks(f(g(h())))`. func (c *MatchClient) Use(hooks ...Hook) { c.hooks.Match = append(c.hooks.Match, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `match.Intercept(f(g(h())))`. func (c *MatchClient) Intercept(interceptors ...Interceptor) { c.inters.Match = append(c.inters.Match, interceptors...) } // Create returns a builder for creating a Match entity. func (c *MatchClient) Create() *MatchCreate { mutation := newMatchMutation(c.config, OpCreate) return &MatchCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Match entities. func (c *MatchClient) CreateBulk(builders ...*MatchCreate) *MatchCreateBulk { return &MatchCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Match. func (c *MatchClient) Update() *MatchUpdate { mutation := newMatchMutation(c.config, OpUpdate) return &MatchUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *MatchClient) UpdateOne(m *Match) *MatchUpdateOne { mutation := newMatchMutation(c.config, OpUpdateOne, withMatch(m)) return &MatchUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *MatchClient) UpdateOneID(id uint64) *MatchUpdateOne { mutation := newMatchMutation(c.config, OpUpdateOne, withMatchID(id)) return &MatchUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Match. func (c *MatchClient) Delete() *MatchDelete { mutation := newMatchMutation(c.config, OpDelete) return &MatchDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *MatchClient) DeleteOne(m *Match) *MatchDeleteOne { return c.DeleteOneID(m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *MatchClient) DeleteOneID(id uint64) *MatchDeleteOne { builder := c.Delete().Where(match.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &MatchDeleteOne{builder} } // Query returns a query builder for Match. func (c *MatchClient) Query() *MatchQuery { return &MatchQuery{ config: c.config, ctx: &QueryContext{Type: TypeMatch}, inters: c.Interceptors(), } } // Get returns a Match entity by its id. func (c *MatchClient) Get(ctx context.Context, id uint64) (*Match, error) { return c.Query().Where(match.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *MatchClient) GetX(ctx context.Context, id uint64) *Match { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryStats queries the stats edge of a Match. func (c *MatchClient) QueryStats(m *Match) *MatchPlayerQuery { query := (&MatchPlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := m.ID step := sqlgraph.NewStep( sqlgraph.From(match.Table, match.FieldID, id), sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, match.StatsTable, match.StatsColumn), ) fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) return fromV, nil } return query } // QueryPlayers queries the players edge of a Match. func (c *MatchClient) QueryPlayers(m *Match) *PlayerQuery { query := (&PlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := m.ID step := sqlgraph.NewStep( sqlgraph.From(match.Table, match.FieldID, id), sqlgraph.To(player.Table, player.FieldID), sqlgraph.Edge(sqlgraph.M2M, true, match.PlayersTable, match.PlayersPrimaryKey...), ) fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *MatchClient) Hooks() []Hook { return c.hooks.Match } // Interceptors returns the client interceptors. func (c *MatchClient) Interceptors() []Interceptor { return c.inters.Match } func (c *MatchClient) mutate(ctx context.Context, m *MatchMutation) (Value, error) { switch m.Op() { case OpCreate: return (&MatchCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&MatchUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&MatchUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&MatchDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Match mutation op: %q", m.Op()) } } // MatchPlayerClient is a client for the MatchPlayer schema. type MatchPlayerClient struct { config } // NewMatchPlayerClient returns a client for the MatchPlayer from the given config. func NewMatchPlayerClient(c config) *MatchPlayerClient { return &MatchPlayerClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `matchplayer.Hooks(f(g(h())))`. func (c *MatchPlayerClient) Use(hooks ...Hook) { c.hooks.MatchPlayer = append(c.hooks.MatchPlayer, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `matchplayer.Intercept(f(g(h())))`. func (c *MatchPlayerClient) Intercept(interceptors ...Interceptor) { c.inters.MatchPlayer = append(c.inters.MatchPlayer, interceptors...) } // Create returns a builder for creating a MatchPlayer entity. func (c *MatchPlayerClient) Create() *MatchPlayerCreate { mutation := newMatchPlayerMutation(c.config, OpCreate) return &MatchPlayerCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of MatchPlayer entities. func (c *MatchPlayerClient) CreateBulk(builders ...*MatchPlayerCreate) *MatchPlayerCreateBulk { return &MatchPlayerCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for MatchPlayer. func (c *MatchPlayerClient) Update() *MatchPlayerUpdate { mutation := newMatchPlayerMutation(c.config, OpUpdate) return &MatchPlayerUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *MatchPlayerClient) UpdateOne(mp *MatchPlayer) *MatchPlayerUpdateOne { mutation := newMatchPlayerMutation(c.config, OpUpdateOne, withMatchPlayer(mp)) return &MatchPlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *MatchPlayerClient) UpdateOneID(id int) *MatchPlayerUpdateOne { mutation := newMatchPlayerMutation(c.config, OpUpdateOne, withMatchPlayerID(id)) return &MatchPlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for MatchPlayer. func (c *MatchPlayerClient) Delete() *MatchPlayerDelete { mutation := newMatchPlayerMutation(c.config, OpDelete) return &MatchPlayerDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *MatchPlayerClient) DeleteOne(mp *MatchPlayer) *MatchPlayerDeleteOne { return c.DeleteOneID(mp.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *MatchPlayerClient) DeleteOneID(id int) *MatchPlayerDeleteOne { builder := c.Delete().Where(matchplayer.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &MatchPlayerDeleteOne{builder} } // Query returns a query builder for MatchPlayer. func (c *MatchPlayerClient) Query() *MatchPlayerQuery { return &MatchPlayerQuery{ config: c.config, ctx: &QueryContext{Type: TypeMatchPlayer}, inters: c.Interceptors(), } } // Get returns a MatchPlayer entity by its id. func (c *MatchPlayerClient) Get(ctx context.Context, id int) (*MatchPlayer, error) { return c.Query().Where(matchplayer.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *MatchPlayerClient) GetX(ctx context.Context, id int) *MatchPlayer { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryMatches queries the matches edge of a MatchPlayer. func (c *MatchPlayerClient) QueryMatches(mp *MatchPlayer) *MatchQuery { query := (&MatchClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := mp.ID step := sqlgraph.NewStep( sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), sqlgraph.To(match.Table, match.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, matchplayer.MatchesTable, matchplayer.MatchesColumn), ) fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step) return fromV, nil } return query } // QueryPlayers queries the players edge of a MatchPlayer. func (c *MatchPlayerClient) QueryPlayers(mp *MatchPlayer) *PlayerQuery { query := (&PlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := mp.ID step := sqlgraph.NewStep( sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), sqlgraph.To(player.Table, player.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, matchplayer.PlayersTable, matchplayer.PlayersColumn), ) fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step) return fromV, nil } return query } // QueryWeaponStats queries the weapon_stats edge of a MatchPlayer. func (c *MatchPlayerClient) QueryWeaponStats(mp *MatchPlayer) *WeaponQuery { query := (&WeaponClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := mp.ID step := sqlgraph.NewStep( sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), sqlgraph.To(weapon.Table, weapon.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.WeaponStatsTable, matchplayer.WeaponStatsColumn), ) fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step) return fromV, nil } return query } // QueryRoundStats queries the round_stats edge of a MatchPlayer. func (c *MatchPlayerClient) QueryRoundStats(mp *MatchPlayer) *RoundStatsQuery { query := (&RoundStatsClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := mp.ID step := sqlgraph.NewStep( sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), sqlgraph.To(roundstats.Table, roundstats.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.RoundStatsTable, matchplayer.RoundStatsColumn), ) fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step) return fromV, nil } return query } // QuerySpray queries the spray edge of a MatchPlayer. func (c *MatchPlayerClient) QuerySpray(mp *MatchPlayer) *SprayQuery { query := (&SprayClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := mp.ID step := sqlgraph.NewStep( sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), sqlgraph.To(spray.Table, spray.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.SprayTable, matchplayer.SprayColumn), ) fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step) return fromV, nil } return query } // QueryMessages queries the messages edge of a MatchPlayer. func (c *MatchPlayerClient) QueryMessages(mp *MatchPlayer) *MessagesQuery { query := (&MessagesClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := mp.ID step := sqlgraph.NewStep( sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), sqlgraph.To(messages.Table, messages.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.MessagesTable, matchplayer.MessagesColumn), ) fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *MatchPlayerClient) Hooks() []Hook { return c.hooks.MatchPlayer } // Interceptors returns the client interceptors. func (c *MatchPlayerClient) Interceptors() []Interceptor { return c.inters.MatchPlayer } func (c *MatchPlayerClient) mutate(ctx context.Context, m *MatchPlayerMutation) (Value, error) { switch m.Op() { case OpCreate: return (&MatchPlayerCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&MatchPlayerUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&MatchPlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&MatchPlayerDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown MatchPlayer mutation op: %q", m.Op()) } } // MessagesClient is a client for the Messages schema. type MessagesClient struct { config } // NewMessagesClient returns a client for the Messages from the given config. func NewMessagesClient(c config) *MessagesClient { return &MessagesClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `messages.Hooks(f(g(h())))`. func (c *MessagesClient) Use(hooks ...Hook) { c.hooks.Messages = append(c.hooks.Messages, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `messages.Intercept(f(g(h())))`. func (c *MessagesClient) Intercept(interceptors ...Interceptor) { c.inters.Messages = append(c.inters.Messages, interceptors...) } // Create returns a builder for creating a Messages entity. func (c *MessagesClient) Create() *MessagesCreate { mutation := newMessagesMutation(c.config, OpCreate) return &MessagesCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Messages entities. func (c *MessagesClient) CreateBulk(builders ...*MessagesCreate) *MessagesCreateBulk { return &MessagesCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Messages. func (c *MessagesClient) Update() *MessagesUpdate { mutation := newMessagesMutation(c.config, OpUpdate) return &MessagesUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *MessagesClient) UpdateOne(m *Messages) *MessagesUpdateOne { mutation := newMessagesMutation(c.config, OpUpdateOne, withMessages(m)) return &MessagesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *MessagesClient) UpdateOneID(id int) *MessagesUpdateOne { mutation := newMessagesMutation(c.config, OpUpdateOne, withMessagesID(id)) return &MessagesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Messages. func (c *MessagesClient) Delete() *MessagesDelete { mutation := newMessagesMutation(c.config, OpDelete) return &MessagesDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *MessagesClient) DeleteOne(m *Messages) *MessagesDeleteOne { return c.DeleteOneID(m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *MessagesClient) DeleteOneID(id int) *MessagesDeleteOne { builder := c.Delete().Where(messages.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &MessagesDeleteOne{builder} } // Query returns a query builder for Messages. func (c *MessagesClient) Query() *MessagesQuery { return &MessagesQuery{ config: c.config, ctx: &QueryContext{Type: TypeMessages}, inters: c.Interceptors(), } } // Get returns a Messages entity by its id. func (c *MessagesClient) Get(ctx context.Context, id int) (*Messages, error) { return c.Query().Where(messages.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *MessagesClient) GetX(ctx context.Context, id int) *Messages { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryMatchPlayer queries the match_player edge of a Messages. func (c *MessagesClient) QueryMatchPlayer(m *Messages) *MatchPlayerQuery { query := (&MatchPlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := m.ID step := sqlgraph.NewStep( sqlgraph.From(messages.Table, messages.FieldID, id), sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, messages.MatchPlayerTable, messages.MatchPlayerColumn), ) fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *MessagesClient) Hooks() []Hook { return c.hooks.Messages } // Interceptors returns the client interceptors. func (c *MessagesClient) Interceptors() []Interceptor { return c.inters.Messages } func (c *MessagesClient) mutate(ctx context.Context, m *MessagesMutation) (Value, error) { switch m.Op() { case OpCreate: return (&MessagesCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&MessagesUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&MessagesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&MessagesDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Messages mutation op: %q", m.Op()) } } // PlayerClient is a client for the Player schema. type PlayerClient struct { config } // NewPlayerClient returns a client for the Player from the given config. func NewPlayerClient(c config) *PlayerClient { return &PlayerClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `player.Hooks(f(g(h())))`. func (c *PlayerClient) Use(hooks ...Hook) { c.hooks.Player = append(c.hooks.Player, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `player.Intercept(f(g(h())))`. func (c *PlayerClient) Intercept(interceptors ...Interceptor) { c.inters.Player = append(c.inters.Player, interceptors...) } // Create returns a builder for creating a Player entity. func (c *PlayerClient) Create() *PlayerCreate { mutation := newPlayerMutation(c.config, OpCreate) return &PlayerCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Player entities. func (c *PlayerClient) CreateBulk(builders ...*PlayerCreate) *PlayerCreateBulk { return &PlayerCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Player. func (c *PlayerClient) Update() *PlayerUpdate { mutation := newPlayerMutation(c.config, OpUpdate) return &PlayerUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *PlayerClient) UpdateOne(pl *Player) *PlayerUpdateOne { mutation := newPlayerMutation(c.config, OpUpdateOne, withPlayer(pl)) return &PlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *PlayerClient) UpdateOneID(id uint64) *PlayerUpdateOne { mutation := newPlayerMutation(c.config, OpUpdateOne, withPlayerID(id)) return &PlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Player. func (c *PlayerClient) Delete() *PlayerDelete { mutation := newPlayerMutation(c.config, OpDelete) return &PlayerDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *PlayerClient) DeleteOne(pl *Player) *PlayerDeleteOne { return c.DeleteOneID(pl.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *PlayerClient) DeleteOneID(id uint64) *PlayerDeleteOne { builder := c.Delete().Where(player.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &PlayerDeleteOne{builder} } // Query returns a query builder for Player. func (c *PlayerClient) Query() *PlayerQuery { return &PlayerQuery{ config: c.config, ctx: &QueryContext{Type: TypePlayer}, inters: c.Interceptors(), } } // Get returns a Player entity by its id. func (c *PlayerClient) Get(ctx context.Context, id uint64) (*Player, error) { return c.Query().Where(player.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *PlayerClient) GetX(ctx context.Context, id uint64) *Player { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryStats queries the stats edge of a Player. func (c *PlayerClient) QueryStats(pl *Player) *MatchPlayerQuery { query := (&MatchPlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := pl.ID step := sqlgraph.NewStep( sqlgraph.From(player.Table, player.FieldID, id), sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, player.StatsTable, player.StatsColumn), ) fromV = sqlgraph.Neighbors(pl.driver.Dialect(), step) return fromV, nil } return query } // QueryMatches queries the matches edge of a Player. func (c *PlayerClient) QueryMatches(pl *Player) *MatchQuery { query := (&MatchClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := pl.ID step := sqlgraph.NewStep( sqlgraph.From(player.Table, player.FieldID, id), sqlgraph.To(match.Table, match.FieldID), sqlgraph.Edge(sqlgraph.M2M, false, player.MatchesTable, player.MatchesPrimaryKey...), ) fromV = sqlgraph.Neighbors(pl.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *PlayerClient) Hooks() []Hook { return c.hooks.Player } // Interceptors returns the client interceptors. func (c *PlayerClient) Interceptors() []Interceptor { return c.inters.Player } func (c *PlayerClient) mutate(ctx context.Context, m *PlayerMutation) (Value, error) { switch m.Op() { case OpCreate: return (&PlayerCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&PlayerUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&PlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&PlayerDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Player mutation op: %q", m.Op()) } } // RoundStatsClient is a client for the RoundStats schema. type RoundStatsClient struct { config } // NewRoundStatsClient returns a client for the RoundStats from the given config. func NewRoundStatsClient(c config) *RoundStatsClient { return &RoundStatsClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `roundstats.Hooks(f(g(h())))`. func (c *RoundStatsClient) Use(hooks ...Hook) { c.hooks.RoundStats = append(c.hooks.RoundStats, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `roundstats.Intercept(f(g(h())))`. func (c *RoundStatsClient) Intercept(interceptors ...Interceptor) { c.inters.RoundStats = append(c.inters.RoundStats, interceptors...) } // Create returns a builder for creating a RoundStats entity. func (c *RoundStatsClient) Create() *RoundStatsCreate { mutation := newRoundStatsMutation(c.config, OpCreate) return &RoundStatsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of RoundStats entities. func (c *RoundStatsClient) CreateBulk(builders ...*RoundStatsCreate) *RoundStatsCreateBulk { return &RoundStatsCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for RoundStats. func (c *RoundStatsClient) Update() *RoundStatsUpdate { mutation := newRoundStatsMutation(c.config, OpUpdate) return &RoundStatsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *RoundStatsClient) UpdateOne(rs *RoundStats) *RoundStatsUpdateOne { mutation := newRoundStatsMutation(c.config, OpUpdateOne, withRoundStats(rs)) return &RoundStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *RoundStatsClient) UpdateOneID(id int) *RoundStatsUpdateOne { mutation := newRoundStatsMutation(c.config, OpUpdateOne, withRoundStatsID(id)) return &RoundStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for RoundStats. func (c *RoundStatsClient) Delete() *RoundStatsDelete { mutation := newRoundStatsMutation(c.config, OpDelete) return &RoundStatsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *RoundStatsClient) DeleteOne(rs *RoundStats) *RoundStatsDeleteOne { return c.DeleteOneID(rs.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *RoundStatsClient) DeleteOneID(id int) *RoundStatsDeleteOne { builder := c.Delete().Where(roundstats.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &RoundStatsDeleteOne{builder} } // Query returns a query builder for RoundStats. func (c *RoundStatsClient) Query() *RoundStatsQuery { return &RoundStatsQuery{ config: c.config, ctx: &QueryContext{Type: TypeRoundStats}, inters: c.Interceptors(), } } // Get returns a RoundStats entity by its id. func (c *RoundStatsClient) Get(ctx context.Context, id int) (*RoundStats, error) { return c.Query().Where(roundstats.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *RoundStatsClient) GetX(ctx context.Context, id int) *RoundStats { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryMatchPlayer queries the match_player edge of a RoundStats. func (c *RoundStatsClient) QueryMatchPlayer(rs *RoundStats) *MatchPlayerQuery { query := (&MatchPlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := rs.ID step := sqlgraph.NewStep( sqlgraph.From(roundstats.Table, roundstats.FieldID, id), sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, roundstats.MatchPlayerTable, roundstats.MatchPlayerColumn), ) fromV = sqlgraph.Neighbors(rs.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *RoundStatsClient) Hooks() []Hook { return c.hooks.RoundStats } // Interceptors returns the client interceptors. func (c *RoundStatsClient) Interceptors() []Interceptor { return c.inters.RoundStats } func (c *RoundStatsClient) mutate(ctx context.Context, m *RoundStatsMutation) (Value, error) { switch m.Op() { case OpCreate: return (&RoundStatsCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&RoundStatsUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&RoundStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&RoundStatsDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown RoundStats mutation op: %q", m.Op()) } } // SprayClient is a client for the Spray schema. type SprayClient struct { config } // NewSprayClient returns a client for the Spray from the given config. func NewSprayClient(c config) *SprayClient { return &SprayClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `spray.Hooks(f(g(h())))`. func (c *SprayClient) Use(hooks ...Hook) { c.hooks.Spray = append(c.hooks.Spray, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `spray.Intercept(f(g(h())))`. func (c *SprayClient) Intercept(interceptors ...Interceptor) { c.inters.Spray = append(c.inters.Spray, interceptors...) } // Create returns a builder for creating a Spray entity. func (c *SprayClient) Create() *SprayCreate { mutation := newSprayMutation(c.config, OpCreate) return &SprayCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Spray entities. func (c *SprayClient) CreateBulk(builders ...*SprayCreate) *SprayCreateBulk { return &SprayCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Spray. func (c *SprayClient) Update() *SprayUpdate { mutation := newSprayMutation(c.config, OpUpdate) return &SprayUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *SprayClient) UpdateOne(s *Spray) *SprayUpdateOne { mutation := newSprayMutation(c.config, OpUpdateOne, withSpray(s)) return &SprayUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *SprayClient) UpdateOneID(id int) *SprayUpdateOne { mutation := newSprayMutation(c.config, OpUpdateOne, withSprayID(id)) return &SprayUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Spray. func (c *SprayClient) Delete() *SprayDelete { mutation := newSprayMutation(c.config, OpDelete) return &SprayDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *SprayClient) DeleteOne(s *Spray) *SprayDeleteOne { return c.DeleteOneID(s.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *SprayClient) DeleteOneID(id int) *SprayDeleteOne { builder := c.Delete().Where(spray.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &SprayDeleteOne{builder} } // Query returns a query builder for Spray. func (c *SprayClient) Query() *SprayQuery { return &SprayQuery{ config: c.config, ctx: &QueryContext{Type: TypeSpray}, inters: c.Interceptors(), } } // Get returns a Spray entity by its id. func (c *SprayClient) Get(ctx context.Context, id int) (*Spray, error) { return c.Query().Where(spray.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *SprayClient) GetX(ctx context.Context, id int) *Spray { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryMatchPlayers queries the match_players edge of a Spray. func (c *SprayClient) QueryMatchPlayers(s *Spray) *MatchPlayerQuery { query := (&MatchPlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := s.ID step := sqlgraph.NewStep( sqlgraph.From(spray.Table, spray.FieldID, id), sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, spray.MatchPlayersTable, spray.MatchPlayersColumn), ) fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *SprayClient) Hooks() []Hook { return c.hooks.Spray } // Interceptors returns the client interceptors. func (c *SprayClient) Interceptors() []Interceptor { return c.inters.Spray } func (c *SprayClient) mutate(ctx context.Context, m *SprayMutation) (Value, error) { switch m.Op() { case OpCreate: return (&SprayCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&SprayUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&SprayUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&SprayDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Spray mutation op: %q", m.Op()) } } // WeaponClient is a client for the Weapon schema. type WeaponClient struct { config } // NewWeaponClient returns a client for the Weapon from the given config. func NewWeaponClient(c config) *WeaponClient { return &WeaponClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `weapon.Hooks(f(g(h())))`. func (c *WeaponClient) Use(hooks ...Hook) { c.hooks.Weapon = append(c.hooks.Weapon, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `weapon.Intercept(f(g(h())))`. func (c *WeaponClient) Intercept(interceptors ...Interceptor) { c.inters.Weapon = append(c.inters.Weapon, interceptors...) } // Create returns a builder for creating a Weapon entity. func (c *WeaponClient) Create() *WeaponCreate { mutation := newWeaponMutation(c.config, OpCreate) return &WeaponCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Weapon entities. func (c *WeaponClient) CreateBulk(builders ...*WeaponCreate) *WeaponCreateBulk { return &WeaponCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Weapon. func (c *WeaponClient) Update() *WeaponUpdate { mutation := newWeaponMutation(c.config, OpUpdate) return &WeaponUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *WeaponClient) UpdateOne(w *Weapon) *WeaponUpdateOne { mutation := newWeaponMutation(c.config, OpUpdateOne, withWeapon(w)) return &WeaponUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *WeaponClient) UpdateOneID(id int) *WeaponUpdateOne { mutation := newWeaponMutation(c.config, OpUpdateOne, withWeaponID(id)) return &WeaponUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Weapon. func (c *WeaponClient) Delete() *WeaponDelete { mutation := newWeaponMutation(c.config, OpDelete) return &WeaponDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *WeaponClient) DeleteOne(w *Weapon) *WeaponDeleteOne { return c.DeleteOneID(w.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *WeaponClient) DeleteOneID(id int) *WeaponDeleteOne { builder := c.Delete().Where(weapon.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &WeaponDeleteOne{builder} } // Query returns a query builder for Weapon. func (c *WeaponClient) Query() *WeaponQuery { return &WeaponQuery{ config: c.config, ctx: &QueryContext{Type: TypeWeapon}, inters: c.Interceptors(), } } // Get returns a Weapon entity by its id. func (c *WeaponClient) Get(ctx context.Context, id int) (*Weapon, error) { return c.Query().Where(weapon.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *WeaponClient) GetX(ctx context.Context, id int) *Weapon { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryStat queries the stat edge of a Weapon. func (c *WeaponClient) QueryStat(w *Weapon) *MatchPlayerQuery { query := (&MatchPlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := w.ID step := sqlgraph.NewStep( sqlgraph.From(weapon.Table, weapon.FieldID, id), sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, weapon.StatTable, weapon.StatColumn), ) fromV = sqlgraph.Neighbors(w.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *WeaponClient) Hooks() []Hook { return c.hooks.Weapon } // Interceptors returns the client interceptors. func (c *WeaponClient) Interceptors() []Interceptor { return c.inters.Weapon } func (c *WeaponClient) mutate(ctx context.Context, m *WeaponMutation) (Value, error) { switch m.Op() { case OpCreate: return (&WeaponCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&WeaponUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&WeaponUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&WeaponDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown Weapon mutation op: %q", m.Op()) } } // hooks and interceptors per client, for fast access. type ( hooks struct { Match, MatchPlayer, Messages, Player, RoundStats, Spray, Weapon []ent.Hook } inters struct { Match, MatchPlayer, Messages, Player, RoundStats, Spray, Weapon []ent.Interceptor } )