// Code generated by entc, DO NOT EDIT. package ent import ( "context" "fmt" "log" "csgowtfd/ent/migrate" "csgowtfd/ent/match" "csgowtfd/ent/player" "csgowtfd/ent/roundstats" "csgowtfd/ent/stats" "csgowtfd/ent/weaponstats" "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 // Match is the client for interacting with the Match builders. Match *MatchClient // Player is the client for interacting with the Player builders. Player *PlayerClient // RoundStats is the client for interacting with the RoundStats builders. RoundStats *RoundStatsClient // Stats is the client for interacting with the Stats builders. Stats *StatsClient // WeaponStats is the client for interacting with the WeaponStats builders. WeaponStats *WeaponStatsClient } // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { cfg := config{log: log.Println, hooks: &hooks{}} 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.Player = NewPlayerClient(c.config) c.RoundStats = NewRoundStatsClient(c.config) c.Stats = NewStatsClient(c.config) c.WeaponStats = NewWeaponStatsClient(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, fmt.Errorf("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), Player: NewPlayerClient(cfg), RoundStats: NewRoundStatsClient(cfg), Stats: NewStatsClient(cfg), WeaponStats: NewWeaponStatsClient(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, fmt.Errorf("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{ config: cfg, Match: NewMatchClient(cfg), Player: NewPlayerClient(cfg), RoundStats: NewRoundStatsClient(cfg), Stats: NewStatsClient(cfg), WeaponStats: NewWeaponStatsClient(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) { c.Match.Use(hooks...) c.Player.Use(hooks...) c.RoundStats.Use(hooks...) c.Stats.Use(hooks...) c.WeaponStats.Use(hooks...) } // 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...) } // Create returns a create builder for Match. 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 delete builder for the given entity. func (c *MatchClient) DeleteOne(m *Match) *MatchDeleteOne { return c.DeleteOneID(m.ID) } // DeleteOneID returns a delete builder for the given 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, } } // 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) *StatsQuery { query := &StatsQuery{config: c.config} query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { id := m.ID step := sqlgraph.NewStep( sqlgraph.From(match.Table, match.FieldID, id), sqlgraph.To(stats.Table, stats.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 := &PlayerQuery{config: c.config} query.path = func(ctx 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 } // 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...) } // Create returns a create builder for Player. 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 delete builder for the given entity. func (c *PlayerClient) DeleteOne(pl *Player) *PlayerDeleteOne { return c.DeleteOneID(pl.ID) } // DeleteOneID returns a delete builder for the given 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, } } // 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) *StatsQuery { query := &StatsQuery{config: c.config} query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { id := pl.ID step := sqlgraph.NewStep( sqlgraph.From(player.Table, player.FieldID, id), sqlgraph.To(stats.Table, stats.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 := &MatchQuery{config: c.config} query.path = func(ctx 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 } // 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...) } // Create returns a create builder for RoundStats. 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 delete builder for the given entity. func (c *RoundStatsClient) DeleteOne(rs *RoundStats) *RoundStatsDeleteOne { return c.DeleteOneID(rs.ID) } // DeleteOneID returns a delete builder for the given 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, } } // 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 } // QueryStat queries the stat edge of a RoundStats. func (c *RoundStatsClient) QueryStat(rs *RoundStats) *StatsQuery { query := &StatsQuery{config: c.config} query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { id := rs.ID step := sqlgraph.NewStep( sqlgraph.From(roundstats.Table, roundstats.FieldID, id), sqlgraph.To(stats.Table, stats.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, roundstats.StatTable, roundstats.StatColumn), ) 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 } // StatsClient is a client for the Stats schema. type StatsClient struct { config } // NewStatsClient returns a client for the Stats from the given config. func NewStatsClient(c config) *StatsClient { return &StatsClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `stats.Hooks(f(g(h())))`. func (c *StatsClient) Use(hooks ...Hook) { c.hooks.Stats = append(c.hooks.Stats, hooks...) } // Create returns a create builder for Stats. func (c *StatsClient) Create() *StatsCreate { mutation := newStatsMutation(c.config, OpCreate) return &StatsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of Stats entities. func (c *StatsClient) CreateBulk(builders ...*StatsCreate) *StatsCreateBulk { return &StatsCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for Stats. func (c *StatsClient) Update() *StatsUpdate { mutation := newStatsMutation(c.config, OpUpdate) return &StatsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *StatsClient) UpdateOne(s *Stats) *StatsUpdateOne { mutation := newStatsMutation(c.config, OpUpdateOne, withStats(s)) return &StatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *StatsClient) UpdateOneID(id int) *StatsUpdateOne { mutation := newStatsMutation(c.config, OpUpdateOne, withStatsID(id)) return &StatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for Stats. func (c *StatsClient) Delete() *StatsDelete { mutation := newStatsMutation(c.config, OpDelete) return &StatsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a delete builder for the given entity. func (c *StatsClient) DeleteOne(s *Stats) *StatsDeleteOne { return c.DeleteOneID(s.ID) } // DeleteOneID returns a delete builder for the given id. func (c *StatsClient) DeleteOneID(id int) *StatsDeleteOne { builder := c.Delete().Where(stats.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &StatsDeleteOne{builder} } // Query returns a query builder for Stats. func (c *StatsClient) Query() *StatsQuery { return &StatsQuery{ config: c.config, } } // Get returns a Stats entity by its id. func (c *StatsClient) Get(ctx context.Context, id int) (*Stats, error) { return c.Query().Where(stats.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *StatsClient) GetX(ctx context.Context, id int) *Stats { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryMatches queries the matches edge of a Stats. func (c *StatsClient) QueryMatches(s *Stats) *MatchQuery { query := &MatchQuery{config: c.config} query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { id := s.ID step := sqlgraph.NewStep( sqlgraph.From(stats.Table, stats.FieldID, id), sqlgraph.To(match.Table, match.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, stats.MatchesTable, stats.MatchesColumn), ) fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) return fromV, nil } return query } // QueryPlayers queries the players edge of a Stats. func (c *StatsClient) QueryPlayers(s *Stats) *PlayerQuery { query := &PlayerQuery{config: c.config} query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { id := s.ID step := sqlgraph.NewStep( sqlgraph.From(stats.Table, stats.FieldID, id), sqlgraph.To(player.Table, player.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, stats.PlayersTable, stats.PlayersColumn), ) fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) return fromV, nil } return query } // QueryWeaponStats queries the weapon_stats edge of a Stats. func (c *StatsClient) QueryWeaponStats(s *Stats) *WeaponStatsQuery { query := &WeaponStatsQuery{config: c.config} query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { id := s.ID step := sqlgraph.NewStep( sqlgraph.From(stats.Table, stats.FieldID, id), sqlgraph.To(weaponstats.Table, weaponstats.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, stats.WeaponStatsTable, stats.WeaponStatsColumn), ) fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) return fromV, nil } return query } // QueryRoundStats queries the round_stats edge of a Stats. func (c *StatsClient) QueryRoundStats(s *Stats) *RoundStatsQuery { query := &RoundStatsQuery{config: c.config} query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { id := s.ID step := sqlgraph.NewStep( sqlgraph.From(stats.Table, stats.FieldID, id), sqlgraph.To(roundstats.Table, roundstats.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, stats.RoundStatsTable, stats.RoundStatsColumn), ) fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *StatsClient) Hooks() []Hook { return c.hooks.Stats } // WeaponStatsClient is a client for the WeaponStats schema. type WeaponStatsClient struct { config } // NewWeaponStatsClient returns a client for the WeaponStats from the given config. func NewWeaponStatsClient(c config) *WeaponStatsClient { return &WeaponStatsClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `weaponstats.Hooks(f(g(h())))`. func (c *WeaponStatsClient) Use(hooks ...Hook) { c.hooks.WeaponStats = append(c.hooks.WeaponStats, hooks...) } // Create returns a create builder for WeaponStats. func (c *WeaponStatsClient) Create() *WeaponStatsCreate { mutation := newWeaponStatsMutation(c.config, OpCreate) return &WeaponStatsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of WeaponStats entities. func (c *WeaponStatsClient) CreateBulk(builders ...*WeaponStatsCreate) *WeaponStatsCreateBulk { return &WeaponStatsCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for WeaponStats. func (c *WeaponStatsClient) Update() *WeaponStatsUpdate { mutation := newWeaponStatsMutation(c.config, OpUpdate) return &WeaponStatsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *WeaponStatsClient) UpdateOne(ws *WeaponStats) *WeaponStatsUpdateOne { mutation := newWeaponStatsMutation(c.config, OpUpdateOne, withWeaponStats(ws)) return &WeaponStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *WeaponStatsClient) UpdateOneID(id int) *WeaponStatsUpdateOne { mutation := newWeaponStatsMutation(c.config, OpUpdateOne, withWeaponStatsID(id)) return &WeaponStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for WeaponStats. func (c *WeaponStatsClient) Delete() *WeaponStatsDelete { mutation := newWeaponStatsMutation(c.config, OpDelete) return &WeaponStatsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a delete builder for the given entity. func (c *WeaponStatsClient) DeleteOne(ws *WeaponStats) *WeaponStatsDeleteOne { return c.DeleteOneID(ws.ID) } // DeleteOneID returns a delete builder for the given id. func (c *WeaponStatsClient) DeleteOneID(id int) *WeaponStatsDeleteOne { builder := c.Delete().Where(weaponstats.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &WeaponStatsDeleteOne{builder} } // Query returns a query builder for WeaponStats. func (c *WeaponStatsClient) Query() *WeaponStatsQuery { return &WeaponStatsQuery{ config: c.config, } } // Get returns a WeaponStats entity by its id. func (c *WeaponStatsClient) Get(ctx context.Context, id int) (*WeaponStats, error) { return c.Query().Where(weaponstats.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *WeaponStatsClient) GetX(ctx context.Context, id int) *WeaponStats { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryStat queries the stat edge of a WeaponStats. func (c *WeaponStatsClient) QueryStat(ws *WeaponStats) *StatsQuery { query := &StatsQuery{config: c.config} query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { id := ws.ID step := sqlgraph.NewStep( sqlgraph.From(weaponstats.Table, weaponstats.FieldID, id), sqlgraph.To(stats.Table, stats.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, weaponstats.StatTable, weaponstats.StatColumn), ) fromV = sqlgraph.Neighbors(ws.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *WeaponStatsClient) Hooks() []Hook { return c.hooks.WeaponStats }