added spray patterns

This commit is contained in:
2021-10-31 08:40:02 +01:00
parent 268793f0e5
commit 978232dd0a
66 changed files with 16805 additions and 11903 deletions

View File

@@ -10,10 +10,11 @@ import (
"csgowtfd/ent/migrate"
"csgowtfd/ent/match"
"csgowtfd/ent/matchplayer"
"csgowtfd/ent/player"
"csgowtfd/ent/roundstats"
"csgowtfd/ent/stats"
"csgowtfd/ent/weaponstats"
"csgowtfd/ent/spray"
"csgowtfd/ent/weapon"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
@@ -27,14 +28,16 @@ type Client struct {
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
// 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
// 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.
@@ -49,10 +52,11 @@ func NewClient(opts ...Option) *Client {
func (c *Client) init() {
c.Schema = migrate.NewSchema(c.driver)
c.Match = NewMatchClient(c.config)
c.MatchPlayer = NewMatchPlayerClient(c.config)
c.Player = NewPlayerClient(c.config)
c.RoundStats = NewRoundStatsClient(c.config)
c.Stats = NewStatsClient(c.config)
c.WeaponStats = NewWeaponStatsClient(c.config)
c.Spray = NewSprayClient(c.config)
c.Weapon = NewWeaponClient(c.config)
}
// Open opens a database/sql.DB specified by the driver name and
@@ -87,10 +91,11 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
ctx: ctx,
config: cfg,
Match: NewMatchClient(cfg),
MatchPlayer: NewMatchPlayerClient(cfg),
Player: NewPlayerClient(cfg),
RoundStats: NewRoundStatsClient(cfg),
Stats: NewStatsClient(cfg),
WeaponStats: NewWeaponStatsClient(cfg),
Spray: NewSprayClient(cfg),
Weapon: NewWeaponClient(cfg),
}, nil
}
@@ -110,10 +115,11 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
return &Tx{
config: cfg,
Match: NewMatchClient(cfg),
MatchPlayer: NewMatchPlayerClient(cfg),
Player: NewPlayerClient(cfg),
RoundStats: NewRoundStatsClient(cfg),
Stats: NewStatsClient(cfg),
WeaponStats: NewWeaponStatsClient(cfg),
Spray: NewSprayClient(cfg),
Weapon: NewWeaponClient(cfg),
}, nil
}
@@ -144,10 +150,11 @@ func (c *Client) Close() error {
// In order to add hooks to a specific client, call: `client.Node.Use(...)`.
func (c *Client) Use(hooks ...Hook) {
c.Match.Use(hooks...)
c.MatchPlayer.Use(hooks...)
c.Player.Use(hooks...)
c.RoundStats.Use(hooks...)
c.Stats.Use(hooks...)
c.WeaponStats.Use(hooks...)
c.Spray.Use(hooks...)
c.Weapon.Use(hooks...)
}
// MatchClient is a client for the Match schema.
@@ -236,13 +243,13 @@ func (c *MatchClient) GetX(ctx context.Context, id uint64) *Match {
}
// QueryStats queries the stats edge of a Match.
func (c *MatchClient) QueryStats(m *Match) *StatsQuery {
query := &StatsQuery{config: c.config}
func (c *MatchClient) QueryStats(m *Match) *MatchPlayerQuery {
query := &MatchPlayerQuery{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.To(matchplayer.Table, matchplayer.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, match.StatsTable, match.StatsColumn),
)
fromV = sqlgraph.Neighbors(m.driver.Dialect(), step)
@@ -272,6 +279,176 @@ func (c *MatchClient) Hooks() []Hook {
return c.hooks.Match
}
// 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...)
}
// Create returns a create builder for MatchPlayer.
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 delete builder for the given entity.
func (c *MatchPlayerClient) DeleteOne(mp *MatchPlayer) *MatchPlayerDeleteOne {
return c.DeleteOneID(mp.ID)
}
// DeleteOneID returns a delete builder for the given 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,
}
}
// 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 := &MatchQuery{config: c.config}
query.path = func(ctx 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 := &PlayerQuery{config: c.config}
query.path = func(ctx 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 := &WeaponQuery{config: c.config}
query.path = func(ctx 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 := &RoundStatsQuery{config: c.config}
query.path = func(ctx 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 := &SprayQuery{config: c.config}
query.path = func(ctx 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
}
// Hooks returns the client hooks.
func (c *MatchPlayerClient) Hooks() []Hook {
return c.hooks.MatchPlayer
}
// PlayerClient is a client for the Player schema.
type PlayerClient struct {
config
@@ -358,13 +535,13 @@ func (c *PlayerClient) GetX(ctx context.Context, id uint64) *Player {
}
// QueryStats queries the stats edge of a Player.
func (c *PlayerClient) QueryStats(pl *Player) *StatsQuery {
query := &StatsQuery{config: c.config}
func (c *PlayerClient) QueryStats(pl *Player) *MatchPlayerQuery {
query := &MatchPlayerQuery{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.To(matchplayer.Table, matchplayer.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, player.StatsTable, player.StatsColumn),
)
fromV = sqlgraph.Neighbors(pl.driver.Dialect(), step)
@@ -479,15 +656,15 @@ func (c *RoundStatsClient) GetX(ctx context.Context, id int) *RoundStats {
return obj
}
// QueryStat queries the stat edge of a RoundStats.
func (c *RoundStatsClient) QueryStat(rs *RoundStats) *StatsQuery {
query := &StatsQuery{config: c.config}
// QueryMatchPlayer queries the match_player edge of a RoundStats.
func (c *RoundStatsClient) QueryMatchPlayer(rs *RoundStats) *MatchPlayerQuery {
query := &MatchPlayerQuery{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),
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
@@ -500,84 +677,84 @@ func (c *RoundStatsClient) Hooks() []Hook {
return c.hooks.RoundStats
}
// StatsClient is a client for the Stats schema.
type StatsClient struct {
// SprayClient is a client for the Spray schema.
type SprayClient struct {
config
}
// NewStatsClient returns a client for the Stats from the given config.
func NewStatsClient(c config) *StatsClient {
return &StatsClient{config: c}
// 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 `stats.Hooks(f(g(h())))`.
func (c *StatsClient) Use(hooks ...Hook) {
c.hooks.Stats = append(c.hooks.Stats, hooks...)
// 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...)
}
// 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}
// Create returns a create builder for Spray.
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 Stats entities.
func (c *StatsClient) CreateBulk(builders ...*StatsCreate) *StatsCreateBulk {
return &StatsCreateBulk{config: c.config, builders: builders}
// 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 Stats.
func (c *StatsClient) Update() *StatsUpdate {
mutation := newStatsMutation(c.config, OpUpdate)
return &StatsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
// 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 *StatsClient) UpdateOne(s *Stats) *StatsUpdateOne {
mutation := newStatsMutation(c.config, OpUpdateOne, withStats(s))
return &StatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
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 *StatsClient) UpdateOneID(id int) *StatsUpdateOne {
mutation := newStatsMutation(c.config, OpUpdateOne, withStatsID(id))
return &StatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
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 Stats.
func (c *StatsClient) Delete() *StatsDelete {
mutation := newStatsMutation(c.config, OpDelete)
return &StatsDelete{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 delete builder for the given entity.
func (c *StatsClient) DeleteOne(s *Stats) *StatsDeleteOne {
func (c *SprayClient) DeleteOne(s *Spray) *SprayDeleteOne {
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))
func (c *SprayClient) DeleteOneID(id int) *SprayDeleteOne {
builder := c.Delete().Where(spray.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &StatsDeleteOne{builder}
return &SprayDeleteOne{builder}
}
// Query returns a query builder for Stats.
func (c *StatsClient) Query() *StatsQuery {
return &StatsQuery{
// Query returns a query builder for Spray.
func (c *SprayClient) Query() *SprayQuery {
return &SprayQuery{
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)
// 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 *StatsClient) GetX(ctx context.Context, id int) *Stats {
func (c *SprayClient) GetX(ctx context.Context, id int) *Spray {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
@@ -585,63 +762,15 @@ func (c *StatsClient) GetX(ctx context.Context, id int) *Stats {
return obj
}
// QueryMatches queries the matches edge of a Stats.
func (c *StatsClient) QueryMatches(s *Stats) *MatchQuery {
query := &MatchQuery{config: c.config}
// QueryMatchPlayers queries the match_players edge of a Spray.
func (c *SprayClient) QueryMatchPlayers(s *Spray) *MatchPlayerQuery {
query := &MatchPlayerQuery{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),
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
@@ -650,88 +779,88 @@ func (c *StatsClient) QueryRoundStats(s *Stats) *RoundStatsQuery {
}
// Hooks returns the client hooks.
func (c *StatsClient) Hooks() []Hook {
return c.hooks.Stats
func (c *SprayClient) Hooks() []Hook {
return c.hooks.Spray
}
// WeaponStatsClient is a client for the WeaponStats schema.
type WeaponStatsClient struct {
// WeaponClient is a client for the Weapon schema.
type WeaponClient struct {
config
}
// NewWeaponStatsClient returns a client for the WeaponStats from the given config.
func NewWeaponStatsClient(c config) *WeaponStatsClient {
return &WeaponStatsClient{config: c}
// 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 `weaponstats.Hooks(f(g(h())))`.
func (c *WeaponStatsClient) Use(hooks ...Hook) {
c.hooks.WeaponStats = append(c.hooks.WeaponStats, hooks...)
// 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...)
}
// 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}
// Create returns a create builder for Weapon.
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 WeaponStats entities.
func (c *WeaponStatsClient) CreateBulk(builders ...*WeaponStatsCreate) *WeaponStatsCreateBulk {
return &WeaponStatsCreateBulk{config: c.config, builders: builders}
// 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 WeaponStats.
func (c *WeaponStatsClient) Update() *WeaponStatsUpdate {
mutation := newWeaponStatsMutation(c.config, OpUpdate)
return &WeaponStatsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
// 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 *WeaponStatsClient) UpdateOne(ws *WeaponStats) *WeaponStatsUpdateOne {
mutation := newWeaponStatsMutation(c.config, OpUpdateOne, withWeaponStats(ws))
return &WeaponStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
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 *WeaponStatsClient) UpdateOneID(id int) *WeaponStatsUpdateOne {
mutation := newWeaponStatsMutation(c.config, OpUpdateOne, withWeaponStatsID(id))
return &WeaponStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
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 WeaponStats.
func (c *WeaponStatsClient) Delete() *WeaponStatsDelete {
mutation := newWeaponStatsMutation(c.config, OpDelete)
return &WeaponStatsDelete{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 delete builder for the given entity.
func (c *WeaponStatsClient) DeleteOne(ws *WeaponStats) *WeaponStatsDeleteOne {
return c.DeleteOneID(ws.ID)
func (c *WeaponClient) DeleteOne(w *Weapon) *WeaponDeleteOne {
return c.DeleteOneID(w.ID)
}
// DeleteOneID returns a delete builder for the given id.
func (c *WeaponStatsClient) DeleteOneID(id int) *WeaponStatsDeleteOne {
builder := c.Delete().Where(weaponstats.ID(id))
func (c *WeaponClient) DeleteOneID(id int) *WeaponDeleteOne {
builder := c.Delete().Where(weapon.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &WeaponStatsDeleteOne{builder}
return &WeaponDeleteOne{builder}
}
// Query returns a query builder for WeaponStats.
func (c *WeaponStatsClient) Query() *WeaponStatsQuery {
return &WeaponStatsQuery{
// Query returns a query builder for Weapon.
func (c *WeaponClient) Query() *WeaponQuery {
return &WeaponQuery{
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)
// 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 *WeaponStatsClient) GetX(ctx context.Context, id int) *WeaponStats {
func (c *WeaponClient) GetX(ctx context.Context, id int) *Weapon {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
@@ -739,23 +868,23 @@ func (c *WeaponStatsClient) GetX(ctx context.Context, id int) *WeaponStats {
return obj
}
// QueryStat queries the stat edge of a WeaponStats.
func (c *WeaponStatsClient) QueryStat(ws *WeaponStats) *StatsQuery {
query := &StatsQuery{config: c.config}
// QueryStat queries the stat edge of a Weapon.
func (c *WeaponClient) QueryStat(w *Weapon) *MatchPlayerQuery {
query := &MatchPlayerQuery{config: c.config}
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
id := ws.ID
id := w.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),
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(ws.driver.Dialect(), step)
fromV = sqlgraph.Neighbors(w.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *WeaponStatsClient) Hooks() []Hook {
return c.hooks.WeaponStats
func (c *WeaponClient) Hooks() []Hook {
return c.hooks.Weapon
}