updated deps; switched sitemap lib; ent regen
This commit is contained in:
338
ent/client.go
338
ent/client.go
@@ -10,6 +10,10 @@ import (
|
||||
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/migrate"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/match"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/messages"
|
||||
@@ -17,10 +21,6 @@ import (
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/roundstats"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/spray"
|
||||
"git.harting.dev/csgowtf/csgowtfd/ent/weapon"
|
||||
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
// Client is the client that holds all ent builders.
|
||||
@@ -46,7 +46,7 @@ type Client struct {
|
||||
|
||||
// NewClient creates a new client configured with the given options.
|
||||
func NewClient(opts ...Option) *Client {
|
||||
cfg := config{log: log.Println, hooks: &hooks{}}
|
||||
cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}}
|
||||
cfg.options(opts...)
|
||||
client := &Client{config: cfg}
|
||||
client.init()
|
||||
@@ -64,6 +64,55 @@ func (c *Client) init() {
|
||||
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.
|
||||
@@ -156,13 +205,43 @@ func (c *Client) Close() error {
|
||||
// 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.MatchPlayer.Use(hooks...)
|
||||
c.Messages.Use(hooks...)
|
||||
c.Player.Use(hooks...)
|
||||
c.RoundStats.Use(hooks...)
|
||||
c.Spray.Use(hooks...)
|
||||
c.Weapon.Use(hooks...)
|
||||
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.
|
||||
@@ -181,6 +260,12 @@ 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)
|
||||
@@ -233,6 +318,8 @@ func (c *MatchClient) DeleteOneID(id uint64) *MatchDeleteOne {
|
||||
func (c *MatchClient) Query() *MatchQuery {
|
||||
return &MatchQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeMatch},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +339,7 @@ func (c *MatchClient) GetX(ctx context.Context, id uint64) *Match {
|
||||
|
||||
// QueryStats queries the stats edge of a Match.
|
||||
func (c *MatchClient) QueryStats(m *Match) *MatchPlayerQuery {
|
||||
query := &MatchPlayerQuery{config: c.config}
|
||||
query := (&MatchPlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
@@ -268,7 +355,7 @@ func (c *MatchClient) QueryStats(m *Match) *MatchPlayerQuery {
|
||||
|
||||
// QueryPlayers queries the players edge of a Match.
|
||||
func (c *MatchClient) QueryPlayers(m *Match) *PlayerQuery {
|
||||
query := &PlayerQuery{config: c.config}
|
||||
query := (&PlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
@@ -287,6 +374,26 @@ 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
|
||||
@@ -303,6 +410,12 @@ 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)
|
||||
@@ -355,6 +468,8 @@ func (c *MatchPlayerClient) DeleteOneID(id int) *MatchPlayerDeleteOne {
|
||||
func (c *MatchPlayerClient) Query() *MatchPlayerQuery {
|
||||
return &MatchPlayerQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeMatchPlayer},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,7 +489,7 @@ func (c *MatchPlayerClient) GetX(ctx context.Context, id int) *MatchPlayer {
|
||||
|
||||
// QueryMatches queries the matches edge of a MatchPlayer.
|
||||
func (c *MatchPlayerClient) QueryMatches(mp *MatchPlayer) *MatchQuery {
|
||||
query := &MatchQuery{config: c.config}
|
||||
query := (&MatchClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := mp.ID
|
||||
step := sqlgraph.NewStep(
|
||||
@@ -390,7 +505,7 @@ func (c *MatchPlayerClient) QueryMatches(mp *MatchPlayer) *MatchQuery {
|
||||
|
||||
// QueryPlayers queries the players edge of a MatchPlayer.
|
||||
func (c *MatchPlayerClient) QueryPlayers(mp *MatchPlayer) *PlayerQuery {
|
||||
query := &PlayerQuery{config: c.config}
|
||||
query := (&PlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := mp.ID
|
||||
step := sqlgraph.NewStep(
|
||||
@@ -406,7 +521,7 @@ func (c *MatchPlayerClient) QueryPlayers(mp *MatchPlayer) *PlayerQuery {
|
||||
|
||||
// QueryWeaponStats queries the weapon_stats edge of a MatchPlayer.
|
||||
func (c *MatchPlayerClient) QueryWeaponStats(mp *MatchPlayer) *WeaponQuery {
|
||||
query := &WeaponQuery{config: c.config}
|
||||
query := (&WeaponClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := mp.ID
|
||||
step := sqlgraph.NewStep(
|
||||
@@ -422,7 +537,7 @@ func (c *MatchPlayerClient) QueryWeaponStats(mp *MatchPlayer) *WeaponQuery {
|
||||
|
||||
// QueryRoundStats queries the round_stats edge of a MatchPlayer.
|
||||
func (c *MatchPlayerClient) QueryRoundStats(mp *MatchPlayer) *RoundStatsQuery {
|
||||
query := &RoundStatsQuery{config: c.config}
|
||||
query := (&RoundStatsClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := mp.ID
|
||||
step := sqlgraph.NewStep(
|
||||
@@ -438,7 +553,7 @@ func (c *MatchPlayerClient) QueryRoundStats(mp *MatchPlayer) *RoundStatsQuery {
|
||||
|
||||
// QuerySpray queries the spray edge of a MatchPlayer.
|
||||
func (c *MatchPlayerClient) QuerySpray(mp *MatchPlayer) *SprayQuery {
|
||||
query := &SprayQuery{config: c.config}
|
||||
query := (&SprayClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := mp.ID
|
||||
step := sqlgraph.NewStep(
|
||||
@@ -454,7 +569,7 @@ func (c *MatchPlayerClient) QuerySpray(mp *MatchPlayer) *SprayQuery {
|
||||
|
||||
// QueryMessages queries the messages edge of a MatchPlayer.
|
||||
func (c *MatchPlayerClient) QueryMessages(mp *MatchPlayer) *MessagesQuery {
|
||||
query := &MessagesQuery{config: c.config}
|
||||
query := (&MessagesClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := mp.ID
|
||||
step := sqlgraph.NewStep(
|
||||
@@ -473,6 +588,26 @@ 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
|
||||
@@ -489,6 +624,12 @@ 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)
|
||||
@@ -541,6 +682,8 @@ func (c *MessagesClient) DeleteOneID(id int) *MessagesDeleteOne {
|
||||
func (c *MessagesClient) Query() *MessagesQuery {
|
||||
return &MessagesQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeMessages},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -560,7 +703,7 @@ func (c *MessagesClient) GetX(ctx context.Context, id int) *Messages {
|
||||
|
||||
// QueryMatchPlayer queries the match_player edge of a Messages.
|
||||
func (c *MessagesClient) QueryMatchPlayer(m *Messages) *MatchPlayerQuery {
|
||||
query := &MatchPlayerQuery{config: c.config}
|
||||
query := (&MatchPlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
@@ -579,6 +722,26 @@ 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
|
||||
@@ -595,6 +758,12 @@ 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)
|
||||
@@ -647,6 +816,8 @@ func (c *PlayerClient) DeleteOneID(id uint64) *PlayerDeleteOne {
|
||||
func (c *PlayerClient) Query() *PlayerQuery {
|
||||
return &PlayerQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypePlayer},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -666,7 +837,7 @@ func (c *PlayerClient) GetX(ctx context.Context, id uint64) *Player {
|
||||
|
||||
// QueryStats queries the stats edge of a Player.
|
||||
func (c *PlayerClient) QueryStats(pl *Player) *MatchPlayerQuery {
|
||||
query := &MatchPlayerQuery{config: c.config}
|
||||
query := (&MatchPlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := pl.ID
|
||||
step := sqlgraph.NewStep(
|
||||
@@ -682,7 +853,7 @@ func (c *PlayerClient) QueryStats(pl *Player) *MatchPlayerQuery {
|
||||
|
||||
// QueryMatches queries the matches edge of a Player.
|
||||
func (c *PlayerClient) QueryMatches(pl *Player) *MatchQuery {
|
||||
query := &MatchQuery{config: c.config}
|
||||
query := (&MatchClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := pl.ID
|
||||
step := sqlgraph.NewStep(
|
||||
@@ -701,6 +872,26 @@ 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
|
||||
@@ -717,6 +908,12 @@ 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)
|
||||
@@ -769,6 +966,8 @@ func (c *RoundStatsClient) DeleteOneID(id int) *RoundStatsDeleteOne {
|
||||
func (c *RoundStatsClient) Query() *RoundStatsQuery {
|
||||
return &RoundStatsQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeRoundStats},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -788,7 +987,7 @@ func (c *RoundStatsClient) GetX(ctx context.Context, id int) *RoundStats {
|
||||
|
||||
// QueryMatchPlayer queries the match_player edge of a RoundStats.
|
||||
func (c *RoundStatsClient) QueryMatchPlayer(rs *RoundStats) *MatchPlayerQuery {
|
||||
query := &MatchPlayerQuery{config: c.config}
|
||||
query := (&MatchPlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := rs.ID
|
||||
step := sqlgraph.NewStep(
|
||||
@@ -807,6 +1006,26 @@ 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
|
||||
@@ -823,6 +1042,12 @@ 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)
|
||||
@@ -875,6 +1100,8 @@ func (c *SprayClient) DeleteOneID(id int) *SprayDeleteOne {
|
||||
func (c *SprayClient) Query() *SprayQuery {
|
||||
return &SprayQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeSpray},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -894,7 +1121,7 @@ func (c *SprayClient) GetX(ctx context.Context, id int) *Spray {
|
||||
|
||||
// QueryMatchPlayers queries the match_players edge of a Spray.
|
||||
func (c *SprayClient) QueryMatchPlayers(s *Spray) *MatchPlayerQuery {
|
||||
query := &MatchPlayerQuery{config: c.config}
|
||||
query := (&MatchPlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := s.ID
|
||||
step := sqlgraph.NewStep(
|
||||
@@ -913,6 +1140,26 @@ 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
|
||||
@@ -929,6 +1176,12 @@ 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)
|
||||
@@ -981,6 +1234,8 @@ func (c *WeaponClient) DeleteOneID(id int) *WeaponDeleteOne {
|
||||
func (c *WeaponClient) Query() *WeaponQuery {
|
||||
return &WeaponQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeWeapon},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1000,7 +1255,7 @@ func (c *WeaponClient) GetX(ctx context.Context, id int) *Weapon {
|
||||
|
||||
// QueryStat queries the stat edge of a Weapon.
|
||||
func (c *WeaponClient) QueryStat(w *Weapon) *MatchPlayerQuery {
|
||||
query := &MatchPlayerQuery{config: c.config}
|
||||
query := (&MatchPlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := w.ID
|
||||
step := sqlgraph.NewStep(
|
||||
@@ -1018,3 +1273,34 @@ func (c *WeaponClient) QueryStat(w *Weapon) *MatchPlayerQuery {
|
||||
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
|
||||
}
|
||||
)
|
||||
|
Reference in New Issue
Block a user