// Code generated by entc, DO NOT EDIT. package ent import ( "context" "csgowtfd/ent/predicate" "csgowtfd/ent/stats" "csgowtfd/ent/weaponstats" "errors" "fmt" "math" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" ) // WeaponStatsQuery is the builder for querying WeaponStats entities. type WeaponStatsQuery struct { config limit *int offset *int unique *bool order []OrderFunc fields []string predicates []predicate.WeaponStats // eager-loading edges. withStat *StatsQuery withFKs bool modifiers []func(s *sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) } // Where adds a new predicate for the WeaponStatsQuery builder. func (wsq *WeaponStatsQuery) Where(ps ...predicate.WeaponStats) *WeaponStatsQuery { wsq.predicates = append(wsq.predicates, ps...) return wsq } // Limit adds a limit step to the query. func (wsq *WeaponStatsQuery) Limit(limit int) *WeaponStatsQuery { wsq.limit = &limit return wsq } // Offset adds an offset step to the query. func (wsq *WeaponStatsQuery) Offset(offset int) *WeaponStatsQuery { wsq.offset = &offset return wsq } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. func (wsq *WeaponStatsQuery) Unique(unique bool) *WeaponStatsQuery { wsq.unique = &unique return wsq } // Order adds an order step to the query. func (wsq *WeaponStatsQuery) Order(o ...OrderFunc) *WeaponStatsQuery { wsq.order = append(wsq.order, o...) return wsq } // QueryStat chains the current query on the "stat" edge. func (wsq *WeaponStatsQuery) QueryStat() *StatsQuery { query := &StatsQuery{config: wsq.config} query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := wsq.prepareQuery(ctx); err != nil { return nil, err } selector := wsq.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } step := sqlgraph.NewStep( sqlgraph.From(weaponstats.Table, weaponstats.FieldID, selector), sqlgraph.To(stats.Table, stats.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, weaponstats.StatTable, weaponstats.StatColumn), ) fromU = sqlgraph.SetNeighbors(wsq.driver.Dialect(), step) return fromU, nil } return query } // First returns the first WeaponStats entity from the query. // Returns a *NotFoundError when no WeaponStats was found. func (wsq *WeaponStatsQuery) First(ctx context.Context) (*WeaponStats, error) { nodes, err := wsq.Limit(1).All(ctx) if err != nil { return nil, err } if len(nodes) == 0 { return nil, &NotFoundError{weaponstats.Label} } return nodes[0], nil } // FirstX is like First, but panics if an error occurs. func (wsq *WeaponStatsQuery) FirstX(ctx context.Context) *WeaponStats { node, err := wsq.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } return node } // FirstID returns the first WeaponStats ID from the query. // Returns a *NotFoundError when no WeaponStats ID was found. func (wsq *WeaponStatsQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int if ids, err = wsq.Limit(1).IDs(ctx); err != nil { return } if len(ids) == 0 { err = &NotFoundError{weaponstats.Label} return } return ids[0], nil } // FirstIDX is like FirstID, but panics if an error occurs. func (wsq *WeaponStatsQuery) FirstIDX(ctx context.Context) int { id, err := wsq.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } return id } // Only returns a single WeaponStats entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when exactly one WeaponStats entity is not found. // Returns a *NotFoundError when no WeaponStats entities are found. func (wsq *WeaponStatsQuery) Only(ctx context.Context) (*WeaponStats, error) { nodes, err := wsq.Limit(2).All(ctx) if err != nil { return nil, err } switch len(nodes) { case 1: return nodes[0], nil case 0: return nil, &NotFoundError{weaponstats.Label} default: return nil, &NotSingularError{weaponstats.Label} } } // OnlyX is like Only, but panics if an error occurs. func (wsq *WeaponStatsQuery) OnlyX(ctx context.Context) *WeaponStats { node, err := wsq.Only(ctx) if err != nil { panic(err) } return node } // OnlyID is like Only, but returns the only WeaponStats ID in the query. // Returns a *NotSingularError when exactly one WeaponStats ID is not found. // Returns a *NotFoundError when no entities are found. func (wsq *WeaponStatsQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int if ids, err = wsq.Limit(2).IDs(ctx); err != nil { return } switch len(ids) { case 1: id = ids[0] case 0: err = &NotFoundError{weaponstats.Label} default: err = &NotSingularError{weaponstats.Label} } return } // OnlyIDX is like OnlyID, but panics if an error occurs. func (wsq *WeaponStatsQuery) OnlyIDX(ctx context.Context) int { id, err := wsq.OnlyID(ctx) if err != nil { panic(err) } return id } // All executes the query and returns a list of WeaponStatsSlice. func (wsq *WeaponStatsQuery) All(ctx context.Context) ([]*WeaponStats, error) { if err := wsq.prepareQuery(ctx); err != nil { return nil, err } return wsq.sqlAll(ctx) } // AllX is like All, but panics if an error occurs. func (wsq *WeaponStatsQuery) AllX(ctx context.Context) []*WeaponStats { nodes, err := wsq.All(ctx) if err != nil { panic(err) } return nodes } // IDs executes the query and returns a list of WeaponStats IDs. func (wsq *WeaponStatsQuery) IDs(ctx context.Context) ([]int, error) { var ids []int if err := wsq.Select(weaponstats.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. func (wsq *WeaponStatsQuery) IDsX(ctx context.Context) []int { ids, err := wsq.IDs(ctx) if err != nil { panic(err) } return ids } // Count returns the count of the given query. func (wsq *WeaponStatsQuery) Count(ctx context.Context) (int, error) { if err := wsq.prepareQuery(ctx); err != nil { return 0, err } return wsq.sqlCount(ctx) } // CountX is like Count, but panics if an error occurs. func (wsq *WeaponStatsQuery) CountX(ctx context.Context) int { count, err := wsq.Count(ctx) if err != nil { panic(err) } return count } // Exist returns true if the query has elements in the graph. func (wsq *WeaponStatsQuery) Exist(ctx context.Context) (bool, error) { if err := wsq.prepareQuery(ctx); err != nil { return false, err } return wsq.sqlExist(ctx) } // ExistX is like Exist, but panics if an error occurs. func (wsq *WeaponStatsQuery) ExistX(ctx context.Context) bool { exist, err := wsq.Exist(ctx) if err != nil { panic(err) } return exist } // Clone returns a duplicate of the WeaponStatsQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. func (wsq *WeaponStatsQuery) Clone() *WeaponStatsQuery { if wsq == nil { return nil } return &WeaponStatsQuery{ config: wsq.config, limit: wsq.limit, offset: wsq.offset, order: append([]OrderFunc{}, wsq.order...), predicates: append([]predicate.WeaponStats{}, wsq.predicates...), withStat: wsq.withStat.Clone(), // clone intermediate query. sql: wsq.sql.Clone(), path: wsq.path, } } // WithStat tells the query-builder to eager-load the nodes that are connected to // the "stat" edge. The optional arguments are used to configure the query builder of the edge. func (wsq *WeaponStatsQuery) WithStat(opts ...func(*StatsQuery)) *WeaponStatsQuery { query := &StatsQuery{config: wsq.config} for _, opt := range opts { opt(query) } wsq.withStat = query return wsq } // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // // Example: // // var v []struct { // Victim uint64 `json:"victim,omitempty"` // Count int `json:"count,omitempty"` // } // // client.WeaponStats.Query(). // GroupBy(weaponstats.FieldVictim). // Aggregate(ent.Count()). // Scan(ctx, &v) // func (wsq *WeaponStatsQuery) GroupBy(field string, fields ...string) *WeaponStatsGroupBy { group := &WeaponStatsGroupBy{config: wsq.config} group.fields = append([]string{field}, fields...) group.path = func(ctx context.Context) (prev *sql.Selector, err error) { if err := wsq.prepareQuery(ctx); err != nil { return nil, err } return wsq.sqlQuery(ctx), nil } return group } // Select allows the selection one or more fields/columns for the given query, // instead of selecting all fields in the entity. // // Example: // // var v []struct { // Victim uint64 `json:"victim,omitempty"` // } // // client.WeaponStats.Query(). // Select(weaponstats.FieldVictim). // Scan(ctx, &v) // func (wsq *WeaponStatsQuery) Select(fields ...string) *WeaponStatsSelect { wsq.fields = append(wsq.fields, fields...) return &WeaponStatsSelect{WeaponStatsQuery: wsq} } func (wsq *WeaponStatsQuery) prepareQuery(ctx context.Context) error { for _, f := range wsq.fields { if !weaponstats.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } if wsq.path != nil { prev, err := wsq.path(ctx) if err != nil { return err } wsq.sql = prev } return nil } func (wsq *WeaponStatsQuery) sqlAll(ctx context.Context) ([]*WeaponStats, error) { var ( nodes = []*WeaponStats{} withFKs = wsq.withFKs _spec = wsq.querySpec() loadedTypes = [1]bool{ wsq.withStat != nil, } ) if wsq.withStat != nil { withFKs = true } if withFKs { _spec.Node.Columns = append(_spec.Node.Columns, weaponstats.ForeignKeys...) } _spec.ScanValues = func(columns []string) ([]interface{}, error) { node := &WeaponStats{config: wsq.config} nodes = append(nodes, node) return node.scanValues(columns) } _spec.Assign = func(columns []string, values []interface{}) error { if len(nodes) == 0 { return fmt.Errorf("ent: Assign called without calling ScanValues") } node := nodes[len(nodes)-1] node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } if len(wsq.modifiers) > 0 { _spec.Modifiers = wsq.modifiers } if err := sqlgraph.QueryNodes(ctx, wsq.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } if query := wsq.withStat; query != nil { ids := make([]int, 0, len(nodes)) nodeids := make(map[int][]*WeaponStats) for i := range nodes { if nodes[i].stats_weapon_stats == nil { continue } fk := *nodes[i].stats_weapon_stats if _, ok := nodeids[fk]; !ok { ids = append(ids, fk) } nodeids[fk] = append(nodeids[fk], nodes[i]) } query.Where(stats.IDIn(ids...)) neighbors, err := query.All(ctx) if err != nil { return nil, err } for _, n := range neighbors { nodes, ok := nodeids[n.ID] if !ok { return nil, fmt.Errorf(`unexpected foreign-key "stats_weapon_stats" returned %v`, n.ID) } for i := range nodes { nodes[i].Edges.Stat = n } } } return nodes, nil } func (wsq *WeaponStatsQuery) sqlCount(ctx context.Context) (int, error) { _spec := wsq.querySpec() if len(wsq.modifiers) > 0 { _spec.Modifiers = wsq.modifiers } return sqlgraph.CountNodes(ctx, wsq.driver, _spec) } func (wsq *WeaponStatsQuery) sqlExist(ctx context.Context) (bool, error) { n, err := wsq.sqlCount(ctx) if err != nil { return false, fmt.Errorf("ent: check existence: %w", err) } return n > 0, nil } func (wsq *WeaponStatsQuery) querySpec() *sqlgraph.QuerySpec { _spec := &sqlgraph.QuerySpec{ Node: &sqlgraph.NodeSpec{ Table: weaponstats.Table, Columns: weaponstats.Columns, ID: &sqlgraph.FieldSpec{ Type: field.TypeInt, Column: weaponstats.FieldID, }, }, From: wsq.sql, Unique: true, } if unique := wsq.unique; unique != nil { _spec.Unique = *unique } if fields := wsq.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, weaponstats.FieldID) for i := range fields { if fields[i] != weaponstats.FieldID { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } } if ps := wsq.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if limit := wsq.limit; limit != nil { _spec.Limit = *limit } if offset := wsq.offset; offset != nil { _spec.Offset = *offset } if ps := wsq.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } return _spec } func (wsq *WeaponStatsQuery) sqlQuery(ctx context.Context) *sql.Selector { builder := sql.Dialect(wsq.driver.Dialect()) t1 := builder.Table(weaponstats.Table) columns := wsq.fields if len(columns) == 0 { columns = weaponstats.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) if wsq.sql != nil { selector = wsq.sql selector.Select(selector.Columns(columns...)...) } for _, m := range wsq.modifiers { m(selector) } for _, p := range wsq.predicates { p(selector) } for _, p := range wsq.order { p(selector) } if offset := wsq.offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } if limit := wsq.limit; limit != nil { selector.Limit(*limit) } return selector } // Modify adds a query modifier for attaching custom logic to queries. func (wsq *WeaponStatsQuery) Modify(modifiers ...func(s *sql.Selector)) *WeaponStatsSelect { wsq.modifiers = append(wsq.modifiers, modifiers...) return wsq.Select() } // WeaponStatsGroupBy is the group-by builder for WeaponStats entities. type WeaponStatsGroupBy struct { config fields []string fns []AggregateFunc // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) } // Aggregate adds the given aggregation functions to the group-by query. func (wsgb *WeaponStatsGroupBy) Aggregate(fns ...AggregateFunc) *WeaponStatsGroupBy { wsgb.fns = append(wsgb.fns, fns...) return wsgb } // Scan applies the group-by query and scans the result into the given value. func (wsgb *WeaponStatsGroupBy) Scan(ctx context.Context, v interface{}) error { query, err := wsgb.path(ctx) if err != nil { return err } wsgb.sql = query return wsgb.sqlScan(ctx, v) } // ScanX is like Scan, but panics if an error occurs. func (wsgb *WeaponStatsGroupBy) ScanX(ctx context.Context, v interface{}) { if err := wsgb.Scan(ctx, v); err != nil { panic(err) } } // Strings returns list of strings from group-by. // It is only allowed when executing a group-by query with one field. func (wsgb *WeaponStatsGroupBy) Strings(ctx context.Context) ([]string, error) { if len(wsgb.fields) > 1 { return nil, errors.New("ent: WeaponStatsGroupBy.Strings is not achievable when grouping more than 1 field") } var v []string if err := wsgb.Scan(ctx, &v); err != nil { return nil, err } return v, nil } // StringsX is like Strings, but panics if an error occurs. func (wsgb *WeaponStatsGroupBy) StringsX(ctx context.Context) []string { v, err := wsgb.Strings(ctx) if err != nil { panic(err) } return v } // String returns a single string from a group-by query. // It is only allowed when executing a group-by query with one field. func (wsgb *WeaponStatsGroupBy) String(ctx context.Context) (_ string, err error) { var v []string if v, err = wsgb.Strings(ctx); err != nil { return } switch len(v) { case 1: return v[0], nil case 0: err = &NotFoundError{weaponstats.Label} default: err = fmt.Errorf("ent: WeaponStatsGroupBy.Strings returned %d results when one was expected", len(v)) } return } // StringX is like String, but panics if an error occurs. func (wsgb *WeaponStatsGroupBy) StringX(ctx context.Context) string { v, err := wsgb.String(ctx) if err != nil { panic(err) } return v } // Ints returns list of ints from group-by. // It is only allowed when executing a group-by query with one field. func (wsgb *WeaponStatsGroupBy) Ints(ctx context.Context) ([]int, error) { if len(wsgb.fields) > 1 { return nil, errors.New("ent: WeaponStatsGroupBy.Ints is not achievable when grouping more than 1 field") } var v []int if err := wsgb.Scan(ctx, &v); err != nil { return nil, err } return v, nil } // IntsX is like Ints, but panics if an error occurs. func (wsgb *WeaponStatsGroupBy) IntsX(ctx context.Context) []int { v, err := wsgb.Ints(ctx) if err != nil { panic(err) } return v } // Int returns a single int from a group-by query. // It is only allowed when executing a group-by query with one field. func (wsgb *WeaponStatsGroupBy) Int(ctx context.Context) (_ int, err error) { var v []int if v, err = wsgb.Ints(ctx); err != nil { return } switch len(v) { case 1: return v[0], nil case 0: err = &NotFoundError{weaponstats.Label} default: err = fmt.Errorf("ent: WeaponStatsGroupBy.Ints returned %d results when one was expected", len(v)) } return } // IntX is like Int, but panics if an error occurs. func (wsgb *WeaponStatsGroupBy) IntX(ctx context.Context) int { v, err := wsgb.Int(ctx) if err != nil { panic(err) } return v } // Float64s returns list of float64s from group-by. // It is only allowed when executing a group-by query with one field. func (wsgb *WeaponStatsGroupBy) Float64s(ctx context.Context) ([]float64, error) { if len(wsgb.fields) > 1 { return nil, errors.New("ent: WeaponStatsGroupBy.Float64s is not achievable when grouping more than 1 field") } var v []float64 if err := wsgb.Scan(ctx, &v); err != nil { return nil, err } return v, nil } // Float64sX is like Float64s, but panics if an error occurs. func (wsgb *WeaponStatsGroupBy) Float64sX(ctx context.Context) []float64 { v, err := wsgb.Float64s(ctx) if err != nil { panic(err) } return v } // Float64 returns a single float64 from a group-by query. // It is only allowed when executing a group-by query with one field. func (wsgb *WeaponStatsGroupBy) Float64(ctx context.Context) (_ float64, err error) { var v []float64 if v, err = wsgb.Float64s(ctx); err != nil { return } switch len(v) { case 1: return v[0], nil case 0: err = &NotFoundError{weaponstats.Label} default: err = fmt.Errorf("ent: WeaponStatsGroupBy.Float64s returned %d results when one was expected", len(v)) } return } // Float64X is like Float64, but panics if an error occurs. func (wsgb *WeaponStatsGroupBy) Float64X(ctx context.Context) float64 { v, err := wsgb.Float64(ctx) if err != nil { panic(err) } return v } // Bools returns list of bools from group-by. // It is only allowed when executing a group-by query with one field. func (wsgb *WeaponStatsGroupBy) Bools(ctx context.Context) ([]bool, error) { if len(wsgb.fields) > 1 { return nil, errors.New("ent: WeaponStatsGroupBy.Bools is not achievable when grouping more than 1 field") } var v []bool if err := wsgb.Scan(ctx, &v); err != nil { return nil, err } return v, nil } // BoolsX is like Bools, but panics if an error occurs. func (wsgb *WeaponStatsGroupBy) BoolsX(ctx context.Context) []bool { v, err := wsgb.Bools(ctx) if err != nil { panic(err) } return v } // Bool returns a single bool from a group-by query. // It is only allowed when executing a group-by query with one field. func (wsgb *WeaponStatsGroupBy) Bool(ctx context.Context) (_ bool, err error) { var v []bool if v, err = wsgb.Bools(ctx); err != nil { return } switch len(v) { case 1: return v[0], nil case 0: err = &NotFoundError{weaponstats.Label} default: err = fmt.Errorf("ent: WeaponStatsGroupBy.Bools returned %d results when one was expected", len(v)) } return } // BoolX is like Bool, but panics if an error occurs. func (wsgb *WeaponStatsGroupBy) BoolX(ctx context.Context) bool { v, err := wsgb.Bool(ctx) if err != nil { panic(err) } return v } func (wsgb *WeaponStatsGroupBy) sqlScan(ctx context.Context, v interface{}) error { for _, f := range wsgb.fields { if !weaponstats.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} } } selector := wsgb.sqlQuery() if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() if err := wsgb.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() return sql.ScanSlice(rows, v) } func (wsgb *WeaponStatsGroupBy) sqlQuery() *sql.Selector { selector := wsgb.sql.Select() aggregation := make([]string, 0, len(wsgb.fns)) for _, fn := range wsgb.fns { aggregation = append(aggregation, fn(selector)) } // If no columns were selected in a custom aggregation function, the default // selection is the fields used for "group-by", and the aggregation functions. if len(selector.SelectedColumns()) == 0 { columns := make([]string, 0, len(wsgb.fields)+len(wsgb.fns)) for _, f := range wsgb.fields { columns = append(columns, selector.C(f)) } for _, c := range aggregation { columns = append(columns, c) } selector.Select(columns...) } return selector.GroupBy(selector.Columns(wsgb.fields...)...) } // WeaponStatsSelect is the builder for selecting fields of WeaponStats entities. type WeaponStatsSelect struct { *WeaponStatsQuery // intermediate query (i.e. traversal path). sql *sql.Selector } // Scan applies the selector query and scans the result into the given value. func (wss *WeaponStatsSelect) Scan(ctx context.Context, v interface{}) error { if err := wss.prepareQuery(ctx); err != nil { return err } wss.sql = wss.WeaponStatsQuery.sqlQuery(ctx) return wss.sqlScan(ctx, v) } // ScanX is like Scan, but panics if an error occurs. func (wss *WeaponStatsSelect) ScanX(ctx context.Context, v interface{}) { if err := wss.Scan(ctx, v); err != nil { panic(err) } } // Strings returns list of strings from a selector. It is only allowed when selecting one field. func (wss *WeaponStatsSelect) Strings(ctx context.Context) ([]string, error) { if len(wss.fields) > 1 { return nil, errors.New("ent: WeaponStatsSelect.Strings is not achievable when selecting more than 1 field") } var v []string if err := wss.Scan(ctx, &v); err != nil { return nil, err } return v, nil } // StringsX is like Strings, but panics if an error occurs. func (wss *WeaponStatsSelect) StringsX(ctx context.Context) []string { v, err := wss.Strings(ctx) if err != nil { panic(err) } return v } // String returns a single string from a selector. It is only allowed when selecting one field. func (wss *WeaponStatsSelect) String(ctx context.Context) (_ string, err error) { var v []string if v, err = wss.Strings(ctx); err != nil { return } switch len(v) { case 1: return v[0], nil case 0: err = &NotFoundError{weaponstats.Label} default: err = fmt.Errorf("ent: WeaponStatsSelect.Strings returned %d results when one was expected", len(v)) } return } // StringX is like String, but panics if an error occurs. func (wss *WeaponStatsSelect) StringX(ctx context.Context) string { v, err := wss.String(ctx) if err != nil { panic(err) } return v } // Ints returns list of ints from a selector. It is only allowed when selecting one field. func (wss *WeaponStatsSelect) Ints(ctx context.Context) ([]int, error) { if len(wss.fields) > 1 { return nil, errors.New("ent: WeaponStatsSelect.Ints is not achievable when selecting more than 1 field") } var v []int if err := wss.Scan(ctx, &v); err != nil { return nil, err } return v, nil } // IntsX is like Ints, but panics if an error occurs. func (wss *WeaponStatsSelect) IntsX(ctx context.Context) []int { v, err := wss.Ints(ctx) if err != nil { panic(err) } return v } // Int returns a single int from a selector. It is only allowed when selecting one field. func (wss *WeaponStatsSelect) Int(ctx context.Context) (_ int, err error) { var v []int if v, err = wss.Ints(ctx); err != nil { return } switch len(v) { case 1: return v[0], nil case 0: err = &NotFoundError{weaponstats.Label} default: err = fmt.Errorf("ent: WeaponStatsSelect.Ints returned %d results when one was expected", len(v)) } return } // IntX is like Int, but panics if an error occurs. func (wss *WeaponStatsSelect) IntX(ctx context.Context) int { v, err := wss.Int(ctx) if err != nil { panic(err) } return v } // Float64s returns list of float64s from a selector. It is only allowed when selecting one field. func (wss *WeaponStatsSelect) Float64s(ctx context.Context) ([]float64, error) { if len(wss.fields) > 1 { return nil, errors.New("ent: WeaponStatsSelect.Float64s is not achievable when selecting more than 1 field") } var v []float64 if err := wss.Scan(ctx, &v); err != nil { return nil, err } return v, nil } // Float64sX is like Float64s, but panics if an error occurs. func (wss *WeaponStatsSelect) Float64sX(ctx context.Context) []float64 { v, err := wss.Float64s(ctx) if err != nil { panic(err) } return v } // Float64 returns a single float64 from a selector. It is only allowed when selecting one field. func (wss *WeaponStatsSelect) Float64(ctx context.Context) (_ float64, err error) { var v []float64 if v, err = wss.Float64s(ctx); err != nil { return } switch len(v) { case 1: return v[0], nil case 0: err = &NotFoundError{weaponstats.Label} default: err = fmt.Errorf("ent: WeaponStatsSelect.Float64s returned %d results when one was expected", len(v)) } return } // Float64X is like Float64, but panics if an error occurs. func (wss *WeaponStatsSelect) Float64X(ctx context.Context) float64 { v, err := wss.Float64(ctx) if err != nil { panic(err) } return v } // Bools returns list of bools from a selector. It is only allowed when selecting one field. func (wss *WeaponStatsSelect) Bools(ctx context.Context) ([]bool, error) { if len(wss.fields) > 1 { return nil, errors.New("ent: WeaponStatsSelect.Bools is not achievable when selecting more than 1 field") } var v []bool if err := wss.Scan(ctx, &v); err != nil { return nil, err } return v, nil } // BoolsX is like Bools, but panics if an error occurs. func (wss *WeaponStatsSelect) BoolsX(ctx context.Context) []bool { v, err := wss.Bools(ctx) if err != nil { panic(err) } return v } // Bool returns a single bool from a selector. It is only allowed when selecting one field. func (wss *WeaponStatsSelect) Bool(ctx context.Context) (_ bool, err error) { var v []bool if v, err = wss.Bools(ctx); err != nil { return } switch len(v) { case 1: return v[0], nil case 0: err = &NotFoundError{weaponstats.Label} default: err = fmt.Errorf("ent: WeaponStatsSelect.Bools returned %d results when one was expected", len(v)) } return } // BoolX is like Bool, but panics if an error occurs. func (wss *WeaponStatsSelect) BoolX(ctx context.Context) bool { v, err := wss.Bool(ctx) if err != nil { panic(err) } return v } func (wss *WeaponStatsSelect) sqlScan(ctx context.Context, v interface{}) error { rows := &sql.Rows{} query, args := wss.sql.Query() if err := wss.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() return sql.ScanSlice(rows, v) } // Modify adds a query modifier for attaching custom logic to queries. func (wss *WeaponStatsSelect) Modify(modifiers ...func(s *sql.Selector)) *WeaponStatsSelect { wss.modifiers = append(wss.modifiers, modifiers...) return wss }