github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/pkg/db/ent/coinfiatcurrencyhistory_query.go (about)

     1  // Code generated by ent, DO NOT EDIT.
     2  
     3  package ent
     4  
     5  import (
     6  	"context"
     7  	"errors"
     8  	"fmt"
     9  	"math"
    10  
    11  	"entgo.io/ent/dialect"
    12  	"entgo.io/ent/dialect/sql"
    13  	"entgo.io/ent/dialect/sql/sqlgraph"
    14  	"entgo.io/ent/schema/field"
    15  	"github.com/NpoolPlatform/chain-middleware/pkg/db/ent/coinfiatcurrencyhistory"
    16  	"github.com/NpoolPlatform/chain-middleware/pkg/db/ent/predicate"
    17  )
    18  
    19  // CoinFiatCurrencyHistoryQuery is the builder for querying CoinFiatCurrencyHistory entities.
    20  type CoinFiatCurrencyHistoryQuery struct {
    21  	config
    22  	limit      *int
    23  	offset     *int
    24  	unique     *bool
    25  	order      []OrderFunc
    26  	fields     []string
    27  	predicates []predicate.CoinFiatCurrencyHistory
    28  	modifiers  []func(*sql.Selector)
    29  	// intermediate query (i.e. traversal path).
    30  	sql  *sql.Selector
    31  	path func(context.Context) (*sql.Selector, error)
    32  }
    33  
    34  // Where adds a new predicate for the CoinFiatCurrencyHistoryQuery builder.
    35  func (cfchq *CoinFiatCurrencyHistoryQuery) Where(ps ...predicate.CoinFiatCurrencyHistory) *CoinFiatCurrencyHistoryQuery {
    36  	cfchq.predicates = append(cfchq.predicates, ps...)
    37  	return cfchq
    38  }
    39  
    40  // Limit adds a limit step to the query.
    41  func (cfchq *CoinFiatCurrencyHistoryQuery) Limit(limit int) *CoinFiatCurrencyHistoryQuery {
    42  	cfchq.limit = &limit
    43  	return cfchq
    44  }
    45  
    46  // Offset adds an offset step to the query.
    47  func (cfchq *CoinFiatCurrencyHistoryQuery) Offset(offset int) *CoinFiatCurrencyHistoryQuery {
    48  	cfchq.offset = &offset
    49  	return cfchq
    50  }
    51  
    52  // Unique configures the query builder to filter duplicate records on query.
    53  // By default, unique is set to true, and can be disabled using this method.
    54  func (cfchq *CoinFiatCurrencyHistoryQuery) Unique(unique bool) *CoinFiatCurrencyHistoryQuery {
    55  	cfchq.unique = &unique
    56  	return cfchq
    57  }
    58  
    59  // Order adds an order step to the query.
    60  func (cfchq *CoinFiatCurrencyHistoryQuery) Order(o ...OrderFunc) *CoinFiatCurrencyHistoryQuery {
    61  	cfchq.order = append(cfchq.order, o...)
    62  	return cfchq
    63  }
    64  
    65  // First returns the first CoinFiatCurrencyHistory entity from the query.
    66  // Returns a *NotFoundError when no CoinFiatCurrencyHistory was found.
    67  func (cfchq *CoinFiatCurrencyHistoryQuery) First(ctx context.Context) (*CoinFiatCurrencyHistory, error) {
    68  	nodes, err := cfchq.Limit(1).All(ctx)
    69  	if err != nil {
    70  		return nil, err
    71  	}
    72  	if len(nodes) == 0 {
    73  		return nil, &NotFoundError{coinfiatcurrencyhistory.Label}
    74  	}
    75  	return nodes[0], nil
    76  }
    77  
    78  // FirstX is like First, but panics if an error occurs.
    79  func (cfchq *CoinFiatCurrencyHistoryQuery) FirstX(ctx context.Context) *CoinFiatCurrencyHistory {
    80  	node, err := cfchq.First(ctx)
    81  	if err != nil && !IsNotFound(err) {
    82  		panic(err)
    83  	}
    84  	return node
    85  }
    86  
    87  // FirstID returns the first CoinFiatCurrencyHistory ID from the query.
    88  // Returns a *NotFoundError when no CoinFiatCurrencyHistory ID was found.
    89  func (cfchq *CoinFiatCurrencyHistoryQuery) FirstID(ctx context.Context) (id uint32, err error) {
    90  	var ids []uint32
    91  	if ids, err = cfchq.Limit(1).IDs(ctx); err != nil {
    92  		return
    93  	}
    94  	if len(ids) == 0 {
    95  		err = &NotFoundError{coinfiatcurrencyhistory.Label}
    96  		return
    97  	}
    98  	return ids[0], nil
    99  }
   100  
   101  // FirstIDX is like FirstID, but panics if an error occurs.
   102  func (cfchq *CoinFiatCurrencyHistoryQuery) FirstIDX(ctx context.Context) uint32 {
   103  	id, err := cfchq.FirstID(ctx)
   104  	if err != nil && !IsNotFound(err) {
   105  		panic(err)
   106  	}
   107  	return id
   108  }
   109  
   110  // Only returns a single CoinFiatCurrencyHistory entity found by the query, ensuring it only returns one.
   111  // Returns a *NotSingularError when more than one CoinFiatCurrencyHistory entity is found.
   112  // Returns a *NotFoundError when no CoinFiatCurrencyHistory entities are found.
   113  func (cfchq *CoinFiatCurrencyHistoryQuery) Only(ctx context.Context) (*CoinFiatCurrencyHistory, error) {
   114  	nodes, err := cfchq.Limit(2).All(ctx)
   115  	if err != nil {
   116  		return nil, err
   117  	}
   118  	switch len(nodes) {
   119  	case 1:
   120  		return nodes[0], nil
   121  	case 0:
   122  		return nil, &NotFoundError{coinfiatcurrencyhistory.Label}
   123  	default:
   124  		return nil, &NotSingularError{coinfiatcurrencyhistory.Label}
   125  	}
   126  }
   127  
   128  // OnlyX is like Only, but panics if an error occurs.
   129  func (cfchq *CoinFiatCurrencyHistoryQuery) OnlyX(ctx context.Context) *CoinFiatCurrencyHistory {
   130  	node, err := cfchq.Only(ctx)
   131  	if err != nil {
   132  		panic(err)
   133  	}
   134  	return node
   135  }
   136  
   137  // OnlyID is like Only, but returns the only CoinFiatCurrencyHistory ID in the query.
   138  // Returns a *NotSingularError when more than one CoinFiatCurrencyHistory ID is found.
   139  // Returns a *NotFoundError when no entities are found.
   140  func (cfchq *CoinFiatCurrencyHistoryQuery) OnlyID(ctx context.Context) (id uint32, err error) {
   141  	var ids []uint32
   142  	if ids, err = cfchq.Limit(2).IDs(ctx); err != nil {
   143  		return
   144  	}
   145  	switch len(ids) {
   146  	case 1:
   147  		id = ids[0]
   148  	case 0:
   149  		err = &NotFoundError{coinfiatcurrencyhistory.Label}
   150  	default:
   151  		err = &NotSingularError{coinfiatcurrencyhistory.Label}
   152  	}
   153  	return
   154  }
   155  
   156  // OnlyIDX is like OnlyID, but panics if an error occurs.
   157  func (cfchq *CoinFiatCurrencyHistoryQuery) OnlyIDX(ctx context.Context) uint32 {
   158  	id, err := cfchq.OnlyID(ctx)
   159  	if err != nil {
   160  		panic(err)
   161  	}
   162  	return id
   163  }
   164  
   165  // All executes the query and returns a list of CoinFiatCurrencyHistories.
   166  func (cfchq *CoinFiatCurrencyHistoryQuery) All(ctx context.Context) ([]*CoinFiatCurrencyHistory, error) {
   167  	if err := cfchq.prepareQuery(ctx); err != nil {
   168  		return nil, err
   169  	}
   170  	return cfchq.sqlAll(ctx)
   171  }
   172  
   173  // AllX is like All, but panics if an error occurs.
   174  func (cfchq *CoinFiatCurrencyHistoryQuery) AllX(ctx context.Context) []*CoinFiatCurrencyHistory {
   175  	nodes, err := cfchq.All(ctx)
   176  	if err != nil {
   177  		panic(err)
   178  	}
   179  	return nodes
   180  }
   181  
   182  // IDs executes the query and returns a list of CoinFiatCurrencyHistory IDs.
   183  func (cfchq *CoinFiatCurrencyHistoryQuery) IDs(ctx context.Context) ([]uint32, error) {
   184  	var ids []uint32
   185  	if err := cfchq.Select(coinfiatcurrencyhistory.FieldID).Scan(ctx, &ids); err != nil {
   186  		return nil, err
   187  	}
   188  	return ids, nil
   189  }
   190  
   191  // IDsX is like IDs, but panics if an error occurs.
   192  func (cfchq *CoinFiatCurrencyHistoryQuery) IDsX(ctx context.Context) []uint32 {
   193  	ids, err := cfchq.IDs(ctx)
   194  	if err != nil {
   195  		panic(err)
   196  	}
   197  	return ids
   198  }
   199  
   200  // Count returns the count of the given query.
   201  func (cfchq *CoinFiatCurrencyHistoryQuery) Count(ctx context.Context) (int, error) {
   202  	if err := cfchq.prepareQuery(ctx); err != nil {
   203  		return 0, err
   204  	}
   205  	return cfchq.sqlCount(ctx)
   206  }
   207  
   208  // CountX is like Count, but panics if an error occurs.
   209  func (cfchq *CoinFiatCurrencyHistoryQuery) CountX(ctx context.Context) int {
   210  	count, err := cfchq.Count(ctx)
   211  	if err != nil {
   212  		panic(err)
   213  	}
   214  	return count
   215  }
   216  
   217  // Exist returns true if the query has elements in the graph.
   218  func (cfchq *CoinFiatCurrencyHistoryQuery) Exist(ctx context.Context) (bool, error) {
   219  	if err := cfchq.prepareQuery(ctx); err != nil {
   220  		return false, err
   221  	}
   222  	return cfchq.sqlExist(ctx)
   223  }
   224  
   225  // ExistX is like Exist, but panics if an error occurs.
   226  func (cfchq *CoinFiatCurrencyHistoryQuery) ExistX(ctx context.Context) bool {
   227  	exist, err := cfchq.Exist(ctx)
   228  	if err != nil {
   229  		panic(err)
   230  	}
   231  	return exist
   232  }
   233  
   234  // Clone returns a duplicate of the CoinFiatCurrencyHistoryQuery builder, including all associated steps. It can be
   235  // used to prepare common query builders and use them differently after the clone is made.
   236  func (cfchq *CoinFiatCurrencyHistoryQuery) Clone() *CoinFiatCurrencyHistoryQuery {
   237  	if cfchq == nil {
   238  		return nil
   239  	}
   240  	return &CoinFiatCurrencyHistoryQuery{
   241  		config:     cfchq.config,
   242  		limit:      cfchq.limit,
   243  		offset:     cfchq.offset,
   244  		order:      append([]OrderFunc{}, cfchq.order...),
   245  		predicates: append([]predicate.CoinFiatCurrencyHistory{}, cfchq.predicates...),
   246  		// clone intermediate query.
   247  		sql:    cfchq.sql.Clone(),
   248  		path:   cfchq.path,
   249  		unique: cfchq.unique,
   250  	}
   251  }
   252  
   253  // GroupBy is used to group vertices by one or more fields/columns.
   254  // It is often used with aggregate functions, like: count, max, mean, min, sum.
   255  //
   256  // Example:
   257  //
   258  //	var v []struct {
   259  //		CreatedAt uint32 `json:"created_at,omitempty"`
   260  //		Count int `json:"count,omitempty"`
   261  //	}
   262  //
   263  //	client.CoinFiatCurrencyHistory.Query().
   264  //		GroupBy(coinfiatcurrencyhistory.FieldCreatedAt).
   265  //		Aggregate(ent.Count()).
   266  //		Scan(ctx, &v)
   267  //
   268  func (cfchq *CoinFiatCurrencyHistoryQuery) GroupBy(field string, fields ...string) *CoinFiatCurrencyHistoryGroupBy {
   269  	grbuild := &CoinFiatCurrencyHistoryGroupBy{config: cfchq.config}
   270  	grbuild.fields = append([]string{field}, fields...)
   271  	grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) {
   272  		if err := cfchq.prepareQuery(ctx); err != nil {
   273  			return nil, err
   274  		}
   275  		return cfchq.sqlQuery(ctx), nil
   276  	}
   277  	grbuild.label = coinfiatcurrencyhistory.Label
   278  	grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan
   279  	return grbuild
   280  }
   281  
   282  // Select allows the selection one or more fields/columns for the given query,
   283  // instead of selecting all fields in the entity.
   284  //
   285  // Example:
   286  //
   287  //	var v []struct {
   288  //		CreatedAt uint32 `json:"created_at,omitempty"`
   289  //	}
   290  //
   291  //	client.CoinFiatCurrencyHistory.Query().
   292  //		Select(coinfiatcurrencyhistory.FieldCreatedAt).
   293  //		Scan(ctx, &v)
   294  //
   295  func (cfchq *CoinFiatCurrencyHistoryQuery) Select(fields ...string) *CoinFiatCurrencyHistorySelect {
   296  	cfchq.fields = append(cfchq.fields, fields...)
   297  	selbuild := &CoinFiatCurrencyHistorySelect{CoinFiatCurrencyHistoryQuery: cfchq}
   298  	selbuild.label = coinfiatcurrencyhistory.Label
   299  	selbuild.flds, selbuild.scan = &cfchq.fields, selbuild.Scan
   300  	return selbuild
   301  }
   302  
   303  func (cfchq *CoinFiatCurrencyHistoryQuery) prepareQuery(ctx context.Context) error {
   304  	for _, f := range cfchq.fields {
   305  		if !coinfiatcurrencyhistory.ValidColumn(f) {
   306  			return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
   307  		}
   308  	}
   309  	if cfchq.path != nil {
   310  		prev, err := cfchq.path(ctx)
   311  		if err != nil {
   312  			return err
   313  		}
   314  		cfchq.sql = prev
   315  	}
   316  	if coinfiatcurrencyhistory.Policy == nil {
   317  		return errors.New("ent: uninitialized coinfiatcurrencyhistory.Policy (forgotten import ent/runtime?)")
   318  	}
   319  	if err := coinfiatcurrencyhistory.Policy.EvalQuery(ctx, cfchq); err != nil {
   320  		return err
   321  	}
   322  	return nil
   323  }
   324  
   325  func (cfchq *CoinFiatCurrencyHistoryQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*CoinFiatCurrencyHistory, error) {
   326  	var (
   327  		nodes = []*CoinFiatCurrencyHistory{}
   328  		_spec = cfchq.querySpec()
   329  	)
   330  	_spec.ScanValues = func(columns []string) ([]interface{}, error) {
   331  		return (*CoinFiatCurrencyHistory).scanValues(nil, columns)
   332  	}
   333  	_spec.Assign = func(columns []string, values []interface{}) error {
   334  		node := &CoinFiatCurrencyHistory{config: cfchq.config}
   335  		nodes = append(nodes, node)
   336  		return node.assignValues(columns, values)
   337  	}
   338  	if len(cfchq.modifiers) > 0 {
   339  		_spec.Modifiers = cfchq.modifiers
   340  	}
   341  	for i := range hooks {
   342  		hooks[i](ctx, _spec)
   343  	}
   344  	if err := sqlgraph.QueryNodes(ctx, cfchq.driver, _spec); err != nil {
   345  		return nil, err
   346  	}
   347  	if len(nodes) == 0 {
   348  		return nodes, nil
   349  	}
   350  	return nodes, nil
   351  }
   352  
   353  func (cfchq *CoinFiatCurrencyHistoryQuery) sqlCount(ctx context.Context) (int, error) {
   354  	_spec := cfchq.querySpec()
   355  	if len(cfchq.modifiers) > 0 {
   356  		_spec.Modifiers = cfchq.modifiers
   357  	}
   358  	_spec.Node.Columns = cfchq.fields
   359  	if len(cfchq.fields) > 0 {
   360  		_spec.Unique = cfchq.unique != nil && *cfchq.unique
   361  	}
   362  	return sqlgraph.CountNodes(ctx, cfchq.driver, _spec)
   363  }
   364  
   365  func (cfchq *CoinFiatCurrencyHistoryQuery) sqlExist(ctx context.Context) (bool, error) {
   366  	n, err := cfchq.sqlCount(ctx)
   367  	if err != nil {
   368  		return false, fmt.Errorf("ent: check existence: %w", err)
   369  	}
   370  	return n > 0, nil
   371  }
   372  
   373  func (cfchq *CoinFiatCurrencyHistoryQuery) querySpec() *sqlgraph.QuerySpec {
   374  	_spec := &sqlgraph.QuerySpec{
   375  		Node: &sqlgraph.NodeSpec{
   376  			Table:   coinfiatcurrencyhistory.Table,
   377  			Columns: coinfiatcurrencyhistory.Columns,
   378  			ID: &sqlgraph.FieldSpec{
   379  				Type:   field.TypeUint32,
   380  				Column: coinfiatcurrencyhistory.FieldID,
   381  			},
   382  		},
   383  		From:   cfchq.sql,
   384  		Unique: true,
   385  	}
   386  	if unique := cfchq.unique; unique != nil {
   387  		_spec.Unique = *unique
   388  	}
   389  	if fields := cfchq.fields; len(fields) > 0 {
   390  		_spec.Node.Columns = make([]string, 0, len(fields))
   391  		_spec.Node.Columns = append(_spec.Node.Columns, coinfiatcurrencyhistory.FieldID)
   392  		for i := range fields {
   393  			if fields[i] != coinfiatcurrencyhistory.FieldID {
   394  				_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
   395  			}
   396  		}
   397  	}
   398  	if ps := cfchq.predicates; len(ps) > 0 {
   399  		_spec.Predicate = func(selector *sql.Selector) {
   400  			for i := range ps {
   401  				ps[i](selector)
   402  			}
   403  		}
   404  	}
   405  	if limit := cfchq.limit; limit != nil {
   406  		_spec.Limit = *limit
   407  	}
   408  	if offset := cfchq.offset; offset != nil {
   409  		_spec.Offset = *offset
   410  	}
   411  	if ps := cfchq.order; len(ps) > 0 {
   412  		_spec.Order = func(selector *sql.Selector) {
   413  			for i := range ps {
   414  				ps[i](selector)
   415  			}
   416  		}
   417  	}
   418  	return _spec
   419  }
   420  
   421  func (cfchq *CoinFiatCurrencyHistoryQuery) sqlQuery(ctx context.Context) *sql.Selector {
   422  	builder := sql.Dialect(cfchq.driver.Dialect())
   423  	t1 := builder.Table(coinfiatcurrencyhistory.Table)
   424  	columns := cfchq.fields
   425  	if len(columns) == 0 {
   426  		columns = coinfiatcurrencyhistory.Columns
   427  	}
   428  	selector := builder.Select(t1.Columns(columns...)...).From(t1)
   429  	if cfchq.sql != nil {
   430  		selector = cfchq.sql
   431  		selector.Select(selector.Columns(columns...)...)
   432  	}
   433  	if cfchq.unique != nil && *cfchq.unique {
   434  		selector.Distinct()
   435  	}
   436  	for _, m := range cfchq.modifiers {
   437  		m(selector)
   438  	}
   439  	for _, p := range cfchq.predicates {
   440  		p(selector)
   441  	}
   442  	for _, p := range cfchq.order {
   443  		p(selector)
   444  	}
   445  	if offset := cfchq.offset; offset != nil {
   446  		// limit is mandatory for offset clause. We start
   447  		// with default value, and override it below if needed.
   448  		selector.Offset(*offset).Limit(math.MaxInt32)
   449  	}
   450  	if limit := cfchq.limit; limit != nil {
   451  		selector.Limit(*limit)
   452  	}
   453  	return selector
   454  }
   455  
   456  // ForUpdate locks the selected rows against concurrent updates, and prevent them from being
   457  // updated, deleted or "selected ... for update" by other sessions, until the transaction is
   458  // either committed or rolled-back.
   459  func (cfchq *CoinFiatCurrencyHistoryQuery) ForUpdate(opts ...sql.LockOption) *CoinFiatCurrencyHistoryQuery {
   460  	if cfchq.driver.Dialect() == dialect.Postgres {
   461  		cfchq.Unique(false)
   462  	}
   463  	cfchq.modifiers = append(cfchq.modifiers, func(s *sql.Selector) {
   464  		s.ForUpdate(opts...)
   465  	})
   466  	return cfchq
   467  }
   468  
   469  // ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock
   470  // on any rows that are read. Other sessions can read the rows, but cannot modify them
   471  // until your transaction commits.
   472  func (cfchq *CoinFiatCurrencyHistoryQuery) ForShare(opts ...sql.LockOption) *CoinFiatCurrencyHistoryQuery {
   473  	if cfchq.driver.Dialect() == dialect.Postgres {
   474  		cfchq.Unique(false)
   475  	}
   476  	cfchq.modifiers = append(cfchq.modifiers, func(s *sql.Selector) {
   477  		s.ForShare(opts...)
   478  	})
   479  	return cfchq
   480  }
   481  
   482  // Modify adds a query modifier for attaching custom logic to queries.
   483  func (cfchq *CoinFiatCurrencyHistoryQuery) Modify(modifiers ...func(s *sql.Selector)) *CoinFiatCurrencyHistorySelect {
   484  	cfchq.modifiers = append(cfchq.modifiers, modifiers...)
   485  	return cfchq.Select()
   486  }
   487  
   488  // CoinFiatCurrencyHistoryGroupBy is the group-by builder for CoinFiatCurrencyHistory entities.
   489  type CoinFiatCurrencyHistoryGroupBy struct {
   490  	config
   491  	selector
   492  	fields []string
   493  	fns    []AggregateFunc
   494  	// intermediate query (i.e. traversal path).
   495  	sql  *sql.Selector
   496  	path func(context.Context) (*sql.Selector, error)
   497  }
   498  
   499  // Aggregate adds the given aggregation functions to the group-by query.
   500  func (cfchgb *CoinFiatCurrencyHistoryGroupBy) Aggregate(fns ...AggregateFunc) *CoinFiatCurrencyHistoryGroupBy {
   501  	cfchgb.fns = append(cfchgb.fns, fns...)
   502  	return cfchgb
   503  }
   504  
   505  // Scan applies the group-by query and scans the result into the given value.
   506  func (cfchgb *CoinFiatCurrencyHistoryGroupBy) Scan(ctx context.Context, v interface{}) error {
   507  	query, err := cfchgb.path(ctx)
   508  	if err != nil {
   509  		return err
   510  	}
   511  	cfchgb.sql = query
   512  	return cfchgb.sqlScan(ctx, v)
   513  }
   514  
   515  func (cfchgb *CoinFiatCurrencyHistoryGroupBy) sqlScan(ctx context.Context, v interface{}) error {
   516  	for _, f := range cfchgb.fields {
   517  		if !coinfiatcurrencyhistory.ValidColumn(f) {
   518  			return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
   519  		}
   520  	}
   521  	selector := cfchgb.sqlQuery()
   522  	if err := selector.Err(); err != nil {
   523  		return err
   524  	}
   525  	rows := &sql.Rows{}
   526  	query, args := selector.Query()
   527  	if err := cfchgb.driver.Query(ctx, query, args, rows); err != nil {
   528  		return err
   529  	}
   530  	defer rows.Close()
   531  	return sql.ScanSlice(rows, v)
   532  }
   533  
   534  func (cfchgb *CoinFiatCurrencyHistoryGroupBy) sqlQuery() *sql.Selector {
   535  	selector := cfchgb.sql.Select()
   536  	aggregation := make([]string, 0, len(cfchgb.fns))
   537  	for _, fn := range cfchgb.fns {
   538  		aggregation = append(aggregation, fn(selector))
   539  	}
   540  	// If no columns were selected in a custom aggregation function, the default
   541  	// selection is the fields used for "group-by", and the aggregation functions.
   542  	if len(selector.SelectedColumns()) == 0 {
   543  		columns := make([]string, 0, len(cfchgb.fields)+len(cfchgb.fns))
   544  		for _, f := range cfchgb.fields {
   545  			columns = append(columns, selector.C(f))
   546  		}
   547  		columns = append(columns, aggregation...)
   548  		selector.Select(columns...)
   549  	}
   550  	return selector.GroupBy(selector.Columns(cfchgb.fields...)...)
   551  }
   552  
   553  // CoinFiatCurrencyHistorySelect is the builder for selecting fields of CoinFiatCurrencyHistory entities.
   554  type CoinFiatCurrencyHistorySelect struct {
   555  	*CoinFiatCurrencyHistoryQuery
   556  	selector
   557  	// intermediate query (i.e. traversal path).
   558  	sql *sql.Selector
   559  }
   560  
   561  // Scan applies the selector query and scans the result into the given value.
   562  func (cfchs *CoinFiatCurrencyHistorySelect) Scan(ctx context.Context, v interface{}) error {
   563  	if err := cfchs.prepareQuery(ctx); err != nil {
   564  		return err
   565  	}
   566  	cfchs.sql = cfchs.CoinFiatCurrencyHistoryQuery.sqlQuery(ctx)
   567  	return cfchs.sqlScan(ctx, v)
   568  }
   569  
   570  func (cfchs *CoinFiatCurrencyHistorySelect) sqlScan(ctx context.Context, v interface{}) error {
   571  	rows := &sql.Rows{}
   572  	query, args := cfchs.sql.Query()
   573  	if err := cfchs.driver.Query(ctx, query, args, rows); err != nil {
   574  		return err
   575  	}
   576  	defer rows.Close()
   577  	return sql.ScanSlice(rows, v)
   578  }
   579  
   580  // Modify adds a query modifier for attaching custom logic to queries.
   581  func (cfchs *CoinFiatCurrencyHistorySelect) Modify(modifiers ...func(s *sql.Selector)) *CoinFiatCurrencyHistorySelect {
   582  	cfchs.modifiers = append(cfchs.modifiers, modifiers...)
   583  	return cfchs
   584  }