regenerate ent
This commit is contained in:
262
ent/client.go
262
ent/client.go
@@ -7,6 +7,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"reflect"
|
||||
|
||||
"somegit.dev/csgowtf/csgowtfd/ent/migrate"
|
||||
|
||||
@@ -46,9 +47,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{}, inters: &inters{}}
|
||||
cfg.options(opts...)
|
||||
client := &Client{config: cfg}
|
||||
client := &Client{config: newConfig(opts...)}
|
||||
client.init()
|
||||
return client
|
||||
}
|
||||
@@ -82,6 +81,13 @@ type (
|
||||
Option func(*config)
|
||||
)
|
||||
|
||||
// newConfig creates a new config for the client.
|
||||
func newConfig(opts ...Option) config {
|
||||
cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}}
|
||||
cfg.options(opts...)
|
||||
return cfg
|
||||
}
|
||||
|
||||
// options applies the options on the config object.
|
||||
func (c *config) options(opts ...Option) {
|
||||
for _, opt := range opts {
|
||||
@@ -129,11 +135,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error)
|
||||
}
|
||||
}
|
||||
|
||||
// ErrTxStarted is returned when trying to start a new transaction from a transactional client.
|
||||
var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction")
|
||||
|
||||
// Tx returns a new transactional client. The provided context
|
||||
// is used until the transaction is committed or rolled back.
|
||||
func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
||||
if _, ok := c.driver.(*txDriver); ok {
|
||||
return nil, errors.New("ent: cannot start a transaction within a transaction")
|
||||
return nil, ErrTxStarted
|
||||
}
|
||||
tx, err := newTx(ctx, c.driver)
|
||||
if err != nil {
|
||||
@@ -277,6 +286,21 @@ func (c *MatchClient) CreateBulk(builders ...*MatchCreate) *MatchCreateBulk {
|
||||
return &MatchCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *MatchClient) MapCreateBulk(slice any, setFunc func(*MatchCreate, int)) *MatchCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &MatchCreateBulk{err: fmt.Errorf("calling to MatchClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*MatchCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &MatchCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Match.
|
||||
func (c *MatchClient) Update() *MatchUpdate {
|
||||
mutation := newMatchMutation(c.config, OpUpdate)
|
||||
@@ -284,8 +308,8 @@ func (c *MatchClient) Update() *MatchUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *MatchClient) UpdateOne(m *Match) *MatchUpdateOne {
|
||||
mutation := newMatchMutation(c.config, OpUpdateOne, withMatch(m))
|
||||
func (c *MatchClient) UpdateOne(_m *Match) *MatchUpdateOne {
|
||||
mutation := newMatchMutation(c.config, OpUpdateOne, withMatch(_m))
|
||||
return &MatchUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -302,8 +326,8 @@ func (c *MatchClient) Delete() *MatchDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *MatchClient) DeleteOne(m *Match) *MatchDeleteOne {
|
||||
return c.DeleteOneID(m.ID)
|
||||
func (c *MatchClient) DeleteOne(_m *Match) *MatchDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -338,32 +362,32 @@ 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 {
|
||||
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
|
||||
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)
|
||||
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 {
|
||||
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
|
||||
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)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -427,6 +451,21 @@ func (c *MatchPlayerClient) CreateBulk(builders ...*MatchPlayerCreate) *MatchPla
|
||||
return &MatchPlayerCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *MatchPlayerClient) MapCreateBulk(slice any, setFunc func(*MatchPlayerCreate, int)) *MatchPlayerCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &MatchPlayerCreateBulk{err: fmt.Errorf("calling to MatchPlayerClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*MatchPlayerCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &MatchPlayerCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for MatchPlayer.
|
||||
func (c *MatchPlayerClient) Update() *MatchPlayerUpdate {
|
||||
mutation := newMatchPlayerMutation(c.config, OpUpdate)
|
||||
@@ -434,8 +473,8 @@ func (c *MatchPlayerClient) Update() *MatchPlayerUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *MatchPlayerClient) UpdateOne(mp *MatchPlayer) *MatchPlayerUpdateOne {
|
||||
mutation := newMatchPlayerMutation(c.config, OpUpdateOne, withMatchPlayer(mp))
|
||||
func (c *MatchPlayerClient) UpdateOne(_m *MatchPlayer) *MatchPlayerUpdateOne {
|
||||
mutation := newMatchPlayerMutation(c.config, OpUpdateOne, withMatchPlayer(_m))
|
||||
return &MatchPlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -452,8 +491,8 @@ func (c *MatchPlayerClient) Delete() *MatchPlayerDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *MatchPlayerClient) DeleteOne(mp *MatchPlayer) *MatchPlayerDeleteOne {
|
||||
return c.DeleteOneID(mp.ID)
|
||||
func (c *MatchPlayerClient) DeleteOne(_m *MatchPlayer) *MatchPlayerDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -488,96 +527,96 @@ 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 {
|
||||
func (c *MatchPlayerClient) QueryMatches(_m *MatchPlayer) *MatchQuery {
|
||||
query := (&MatchClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := mp.ID
|
||||
id := _m.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)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryPlayers queries the players edge of a MatchPlayer.
|
||||
func (c *MatchPlayerClient) QueryPlayers(mp *MatchPlayer) *PlayerQuery {
|
||||
func (c *MatchPlayerClient) QueryPlayers(_m *MatchPlayer) *PlayerQuery {
|
||||
query := (&PlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := mp.ID
|
||||
id := _m.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)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryWeaponStats queries the weapon_stats edge of a MatchPlayer.
|
||||
func (c *MatchPlayerClient) QueryWeaponStats(mp *MatchPlayer) *WeaponQuery {
|
||||
func (c *MatchPlayerClient) QueryWeaponStats(_m *MatchPlayer) *WeaponQuery {
|
||||
query := (&WeaponClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := mp.ID
|
||||
id := _m.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)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryRoundStats queries the round_stats edge of a MatchPlayer.
|
||||
func (c *MatchPlayerClient) QueryRoundStats(mp *MatchPlayer) *RoundStatsQuery {
|
||||
func (c *MatchPlayerClient) QueryRoundStats(_m *MatchPlayer) *RoundStatsQuery {
|
||||
query := (&RoundStatsClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := mp.ID
|
||||
id := _m.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)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QuerySpray queries the spray edge of a MatchPlayer.
|
||||
func (c *MatchPlayerClient) QuerySpray(mp *MatchPlayer) *SprayQuery {
|
||||
func (c *MatchPlayerClient) QuerySpray(_m *MatchPlayer) *SprayQuery {
|
||||
query := (&SprayClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := mp.ID
|
||||
id := _m.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)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryMessages queries the messages edge of a MatchPlayer.
|
||||
func (c *MatchPlayerClient) QueryMessages(mp *MatchPlayer) *MessagesQuery {
|
||||
func (c *MatchPlayerClient) QueryMessages(_m *MatchPlayer) *MessagesQuery {
|
||||
query := (&MessagesClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := mp.ID
|
||||
id := _m.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)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -641,6 +680,21 @@ func (c *MessagesClient) CreateBulk(builders ...*MessagesCreate) *MessagesCreate
|
||||
return &MessagesCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *MessagesClient) MapCreateBulk(slice any, setFunc func(*MessagesCreate, int)) *MessagesCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &MessagesCreateBulk{err: fmt.Errorf("calling to MessagesClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*MessagesCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &MessagesCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Messages.
|
||||
func (c *MessagesClient) Update() *MessagesUpdate {
|
||||
mutation := newMessagesMutation(c.config, OpUpdate)
|
||||
@@ -648,8 +702,8 @@ func (c *MessagesClient) Update() *MessagesUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *MessagesClient) UpdateOne(m *Messages) *MessagesUpdateOne {
|
||||
mutation := newMessagesMutation(c.config, OpUpdateOne, withMessages(m))
|
||||
func (c *MessagesClient) UpdateOne(_m *Messages) *MessagesUpdateOne {
|
||||
mutation := newMessagesMutation(c.config, OpUpdateOne, withMessages(_m))
|
||||
return &MessagesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -666,8 +720,8 @@ func (c *MessagesClient) Delete() *MessagesDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *MessagesClient) DeleteOne(m *Messages) *MessagesDeleteOne {
|
||||
return c.DeleteOneID(m.ID)
|
||||
func (c *MessagesClient) DeleteOne(_m *Messages) *MessagesDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -702,16 +756,16 @@ 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 {
|
||||
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
|
||||
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)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -775,6 +829,21 @@ func (c *PlayerClient) CreateBulk(builders ...*PlayerCreate) *PlayerCreateBulk {
|
||||
return &PlayerCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *PlayerClient) MapCreateBulk(slice any, setFunc func(*PlayerCreate, int)) *PlayerCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &PlayerCreateBulk{err: fmt.Errorf("calling to PlayerClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*PlayerCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &PlayerCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Player.
|
||||
func (c *PlayerClient) Update() *PlayerUpdate {
|
||||
mutation := newPlayerMutation(c.config, OpUpdate)
|
||||
@@ -782,8 +851,8 @@ func (c *PlayerClient) Update() *PlayerUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *PlayerClient) UpdateOne(pl *Player) *PlayerUpdateOne {
|
||||
mutation := newPlayerMutation(c.config, OpUpdateOne, withPlayer(pl))
|
||||
func (c *PlayerClient) UpdateOne(_m *Player) *PlayerUpdateOne {
|
||||
mutation := newPlayerMutation(c.config, OpUpdateOne, withPlayer(_m))
|
||||
return &PlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -800,8 +869,8 @@ func (c *PlayerClient) Delete() *PlayerDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *PlayerClient) DeleteOne(pl *Player) *PlayerDeleteOne {
|
||||
return c.DeleteOneID(pl.ID)
|
||||
func (c *PlayerClient) DeleteOne(_m *Player) *PlayerDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -836,32 +905,32 @@ 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 {
|
||||
func (c *PlayerClient) QueryStats(_m *Player) *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := pl.ID
|
||||
id := _m.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)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryMatches queries the matches edge of a Player.
|
||||
func (c *PlayerClient) QueryMatches(pl *Player) *MatchQuery {
|
||||
func (c *PlayerClient) QueryMatches(_m *Player) *MatchQuery {
|
||||
query := (&MatchClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := pl.ID
|
||||
id := _m.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)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -925,6 +994,21 @@ func (c *RoundStatsClient) CreateBulk(builders ...*RoundStatsCreate) *RoundStats
|
||||
return &RoundStatsCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *RoundStatsClient) MapCreateBulk(slice any, setFunc func(*RoundStatsCreate, int)) *RoundStatsCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &RoundStatsCreateBulk{err: fmt.Errorf("calling to RoundStatsClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*RoundStatsCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &RoundStatsCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for RoundStats.
|
||||
func (c *RoundStatsClient) Update() *RoundStatsUpdate {
|
||||
mutation := newRoundStatsMutation(c.config, OpUpdate)
|
||||
@@ -932,8 +1016,8 @@ func (c *RoundStatsClient) Update() *RoundStatsUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *RoundStatsClient) UpdateOne(rs *RoundStats) *RoundStatsUpdateOne {
|
||||
mutation := newRoundStatsMutation(c.config, OpUpdateOne, withRoundStats(rs))
|
||||
func (c *RoundStatsClient) UpdateOne(_m *RoundStats) *RoundStatsUpdateOne {
|
||||
mutation := newRoundStatsMutation(c.config, OpUpdateOne, withRoundStats(_m))
|
||||
return &RoundStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -950,8 +1034,8 @@ func (c *RoundStatsClient) Delete() *RoundStatsDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *RoundStatsClient) DeleteOne(rs *RoundStats) *RoundStatsDeleteOne {
|
||||
return c.DeleteOneID(rs.ID)
|
||||
func (c *RoundStatsClient) DeleteOne(_m *RoundStats) *RoundStatsDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -986,16 +1070,16 @@ 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 {
|
||||
func (c *RoundStatsClient) QueryMatchPlayer(_m *RoundStats) *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := rs.ID
|
||||
id := _m.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)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -1059,6 +1143,21 @@ func (c *SprayClient) CreateBulk(builders ...*SprayCreate) *SprayCreateBulk {
|
||||
return &SprayCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *SprayClient) MapCreateBulk(slice any, setFunc func(*SprayCreate, int)) *SprayCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &SprayCreateBulk{err: fmt.Errorf("calling to SprayClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*SprayCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &SprayCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Spray.
|
||||
func (c *SprayClient) Update() *SprayUpdate {
|
||||
mutation := newSprayMutation(c.config, OpUpdate)
|
||||
@@ -1066,8 +1165,8 @@ func (c *SprayClient) Update() *SprayUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *SprayClient) UpdateOne(s *Spray) *SprayUpdateOne {
|
||||
mutation := newSprayMutation(c.config, OpUpdateOne, withSpray(s))
|
||||
func (c *SprayClient) UpdateOne(_m *Spray) *SprayUpdateOne {
|
||||
mutation := newSprayMutation(c.config, OpUpdateOne, withSpray(_m))
|
||||
return &SprayUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -1084,8 +1183,8 @@ func (c *SprayClient) Delete() *SprayDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *SprayClient) DeleteOne(s *Spray) *SprayDeleteOne {
|
||||
return c.DeleteOneID(s.ID)
|
||||
func (c *SprayClient) DeleteOne(_m *Spray) *SprayDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -1120,16 +1219,16 @@ 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 {
|
||||
func (c *SprayClient) QueryMatchPlayers(_m *Spray) *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := s.ID
|
||||
id := _m.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)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -1193,6 +1292,21 @@ func (c *WeaponClient) CreateBulk(builders ...*WeaponCreate) *WeaponCreateBulk {
|
||||
return &WeaponCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *WeaponClient) MapCreateBulk(slice any, setFunc func(*WeaponCreate, int)) *WeaponCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &WeaponCreateBulk{err: fmt.Errorf("calling to WeaponClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*WeaponCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &WeaponCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Weapon.
|
||||
func (c *WeaponClient) Update() *WeaponUpdate {
|
||||
mutation := newWeaponMutation(c.config, OpUpdate)
|
||||
@@ -1200,8 +1314,8 @@ func (c *WeaponClient) Update() *WeaponUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *WeaponClient) UpdateOne(w *Weapon) *WeaponUpdateOne {
|
||||
mutation := newWeaponMutation(c.config, OpUpdateOne, withWeapon(w))
|
||||
func (c *WeaponClient) UpdateOne(_m *Weapon) *WeaponUpdateOne {
|
||||
mutation := newWeaponMutation(c.config, OpUpdateOne, withWeapon(_m))
|
||||
return &WeaponUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -1218,8 +1332,8 @@ func (c *WeaponClient) Delete() *WeaponDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *WeaponClient) DeleteOne(w *Weapon) *WeaponDeleteOne {
|
||||
return c.DeleteOneID(w.ID)
|
||||
func (c *WeaponClient) DeleteOne(_m *Weapon) *WeaponDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -1254,16 +1368,16 @@ 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 {
|
||||
func (c *WeaponClient) QueryStat(_m *Weapon) *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := w.ID
|
||||
id := _m.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)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
|
||||
Reference in New Issue
Block a user