[feature] migrate to monorepo
This commit is contained in:
commit
05ddc1f783
267 changed files with 75165 additions and 0 deletions
614
backend/ent/dailycategorycontent_query.go
Normal file
614
backend/ent/dailycategorycontent_query.go
Normal file
|
@ -0,0 +1,614 @@
|
|||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"tss-rocks-be/ent/dailycategory"
|
||||
"tss-rocks-be/ent/dailycategorycontent"
|
||||
"tss-rocks-be/ent/predicate"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// DailyCategoryContentQuery is the builder for querying DailyCategoryContent entities.
|
||||
type DailyCategoryContentQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []dailycategorycontent.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.DailyCategoryContent
|
||||
withCategory *DailyCategoryQuery
|
||||
withFKs bool
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the DailyCategoryContentQuery builder.
|
||||
func (dccq *DailyCategoryContentQuery) Where(ps ...predicate.DailyCategoryContent) *DailyCategoryContentQuery {
|
||||
dccq.predicates = append(dccq.predicates, ps...)
|
||||
return dccq
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (dccq *DailyCategoryContentQuery) Limit(limit int) *DailyCategoryContentQuery {
|
||||
dccq.ctx.Limit = &limit
|
||||
return dccq
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (dccq *DailyCategoryContentQuery) Offset(offset int) *DailyCategoryContentQuery {
|
||||
dccq.ctx.Offset = &offset
|
||||
return dccq
|
||||
}
|
||||
|
||||
// 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 (dccq *DailyCategoryContentQuery) Unique(unique bool) *DailyCategoryContentQuery {
|
||||
dccq.ctx.Unique = &unique
|
||||
return dccq
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (dccq *DailyCategoryContentQuery) Order(o ...dailycategorycontent.OrderOption) *DailyCategoryContentQuery {
|
||||
dccq.order = append(dccq.order, o...)
|
||||
return dccq
|
||||
}
|
||||
|
||||
// QueryCategory chains the current query on the "category" edge.
|
||||
func (dccq *DailyCategoryContentQuery) QueryCategory() *DailyCategoryQuery {
|
||||
query := (&DailyCategoryClient{config: dccq.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := dccq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := dccq.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(dailycategorycontent.Table, dailycategorycontent.FieldID, selector),
|
||||
sqlgraph.To(dailycategory.Table, dailycategory.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, dailycategorycontent.CategoryTable, dailycategorycontent.CategoryColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(dccq.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first DailyCategoryContent entity from the query.
|
||||
// Returns a *NotFoundError when no DailyCategoryContent was found.
|
||||
func (dccq *DailyCategoryContentQuery) First(ctx context.Context) (*DailyCategoryContent, error) {
|
||||
nodes, err := dccq.Limit(1).All(setContextOp(ctx, dccq.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{dailycategorycontent.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (dccq *DailyCategoryContentQuery) FirstX(ctx context.Context) *DailyCategoryContent {
|
||||
node, err := dccq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first DailyCategoryContent ID from the query.
|
||||
// Returns a *NotFoundError when no DailyCategoryContent ID was found.
|
||||
func (dccq *DailyCategoryContentQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = dccq.Limit(1).IDs(setContextOp(ctx, dccq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{dailycategorycontent.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (dccq *DailyCategoryContentQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := dccq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single DailyCategoryContent entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one DailyCategoryContent entity is found.
|
||||
// Returns a *NotFoundError when no DailyCategoryContent entities are found.
|
||||
func (dccq *DailyCategoryContentQuery) Only(ctx context.Context) (*DailyCategoryContent, error) {
|
||||
nodes, err := dccq.Limit(2).All(setContextOp(ctx, dccq.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{dailycategorycontent.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{dailycategorycontent.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (dccq *DailyCategoryContentQuery) OnlyX(ctx context.Context) *DailyCategoryContent {
|
||||
node, err := dccq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only DailyCategoryContent ID in the query.
|
||||
// Returns a *NotSingularError when more than one DailyCategoryContent ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (dccq *DailyCategoryContentQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = dccq.Limit(2).IDs(setContextOp(ctx, dccq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{dailycategorycontent.Label}
|
||||
default:
|
||||
err = &NotSingularError{dailycategorycontent.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (dccq *DailyCategoryContentQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := dccq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of DailyCategoryContents.
|
||||
func (dccq *DailyCategoryContentQuery) All(ctx context.Context) ([]*DailyCategoryContent, error) {
|
||||
ctx = setContextOp(ctx, dccq.ctx, ent.OpQueryAll)
|
||||
if err := dccq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*DailyCategoryContent, *DailyCategoryContentQuery]()
|
||||
return withInterceptors[[]*DailyCategoryContent](ctx, dccq, qr, dccq.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (dccq *DailyCategoryContentQuery) AllX(ctx context.Context) []*DailyCategoryContent {
|
||||
nodes, err := dccq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of DailyCategoryContent IDs.
|
||||
func (dccq *DailyCategoryContentQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if dccq.ctx.Unique == nil && dccq.path != nil {
|
||||
dccq.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, dccq.ctx, ent.OpQueryIDs)
|
||||
if err = dccq.Select(dailycategorycontent.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (dccq *DailyCategoryContentQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := dccq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (dccq *DailyCategoryContentQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, dccq.ctx, ent.OpQueryCount)
|
||||
if err := dccq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, dccq, querierCount[*DailyCategoryContentQuery](), dccq.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (dccq *DailyCategoryContentQuery) CountX(ctx context.Context) int {
|
||||
count, err := dccq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (dccq *DailyCategoryContentQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, dccq.ctx, ent.OpQueryExist)
|
||||
switch _, err := dccq.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||
default:
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (dccq *DailyCategoryContentQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := dccq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the DailyCategoryContentQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (dccq *DailyCategoryContentQuery) Clone() *DailyCategoryContentQuery {
|
||||
if dccq == nil {
|
||||
return nil
|
||||
}
|
||||
return &DailyCategoryContentQuery{
|
||||
config: dccq.config,
|
||||
ctx: dccq.ctx.Clone(),
|
||||
order: append([]dailycategorycontent.OrderOption{}, dccq.order...),
|
||||
inters: append([]Interceptor{}, dccq.inters...),
|
||||
predicates: append([]predicate.DailyCategoryContent{}, dccq.predicates...),
|
||||
withCategory: dccq.withCategory.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: dccq.sql.Clone(),
|
||||
path: dccq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithCategory tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "category" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (dccq *DailyCategoryContentQuery) WithCategory(opts ...func(*DailyCategoryQuery)) *DailyCategoryContentQuery {
|
||||
query := (&DailyCategoryClient{config: dccq.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
dccq.withCategory = query
|
||||
return dccq
|
||||
}
|
||||
|
||||
// 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 {
|
||||
// LanguageCode dailycategorycontent.LanguageCode `json:"language_code,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.DailyCategoryContent.Query().
|
||||
// GroupBy(dailycategorycontent.FieldLanguageCode).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (dccq *DailyCategoryContentQuery) GroupBy(field string, fields ...string) *DailyCategoryContentGroupBy {
|
||||
dccq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &DailyCategoryContentGroupBy{build: dccq}
|
||||
grbuild.flds = &dccq.ctx.Fields
|
||||
grbuild.label = dailycategorycontent.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
}
|
||||
|
||||
// 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 {
|
||||
// LanguageCode dailycategorycontent.LanguageCode `json:"language_code,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.DailyCategoryContent.Query().
|
||||
// Select(dailycategorycontent.FieldLanguageCode).
|
||||
// Scan(ctx, &v)
|
||||
func (dccq *DailyCategoryContentQuery) Select(fields ...string) *DailyCategoryContentSelect {
|
||||
dccq.ctx.Fields = append(dccq.ctx.Fields, fields...)
|
||||
sbuild := &DailyCategoryContentSelect{DailyCategoryContentQuery: dccq}
|
||||
sbuild.label = dailycategorycontent.Label
|
||||
sbuild.flds, sbuild.scan = &dccq.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a DailyCategoryContentSelect configured with the given aggregations.
|
||||
func (dccq *DailyCategoryContentQuery) Aggregate(fns ...AggregateFunc) *DailyCategoryContentSelect {
|
||||
return dccq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (dccq *DailyCategoryContentQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range dccq.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, dccq); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range dccq.ctx.Fields {
|
||||
if !dailycategorycontent.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if dccq.path != nil {
|
||||
prev, err := dccq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dccq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dccq *DailyCategoryContentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*DailyCategoryContent, error) {
|
||||
var (
|
||||
nodes = []*DailyCategoryContent{}
|
||||
withFKs = dccq.withFKs
|
||||
_spec = dccq.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
dccq.withCategory != nil,
|
||||
}
|
||||
)
|
||||
if dccq.withCategory != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, dailycategorycontent.ForeignKeys...)
|
||||
}
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*DailyCategoryContent).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &DailyCategoryContent{config: dccq.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, dccq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := dccq.withCategory; query != nil {
|
||||
if err := dccq.loadCategory(ctx, query, nodes, nil,
|
||||
func(n *DailyCategoryContent, e *DailyCategory) { n.Edges.Category = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (dccq *DailyCategoryContentQuery) loadCategory(ctx context.Context, query *DailyCategoryQuery, nodes []*DailyCategoryContent, init func(*DailyCategoryContent), assign func(*DailyCategoryContent, *DailyCategory)) error {
|
||||
ids := make([]int, 0, len(nodes))
|
||||
nodeids := make(map[int][]*DailyCategoryContent)
|
||||
for i := range nodes {
|
||||
if nodes[i].daily_category_contents == nil {
|
||||
continue
|
||||
}
|
||||
fk := *nodes[i].daily_category_contents
|
||||
if _, ok := nodeids[fk]; !ok {
|
||||
ids = append(ids, fk)
|
||||
}
|
||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
query.Where(dailycategory.IDIn(ids...))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nodeids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "daily_category_contents" returned %v`, n.ID)
|
||||
}
|
||||
for i := range nodes {
|
||||
assign(nodes[i], n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dccq *DailyCategoryContentQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := dccq.querySpec()
|
||||
_spec.Node.Columns = dccq.ctx.Fields
|
||||
if len(dccq.ctx.Fields) > 0 {
|
||||
_spec.Unique = dccq.ctx.Unique != nil && *dccq.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, dccq.driver, _spec)
|
||||
}
|
||||
|
||||
func (dccq *DailyCategoryContentQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(dailycategorycontent.Table, dailycategorycontent.Columns, sqlgraph.NewFieldSpec(dailycategorycontent.FieldID, field.TypeInt))
|
||||
_spec.From = dccq.sql
|
||||
if unique := dccq.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if dccq.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := dccq.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, dailycategorycontent.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != dailycategorycontent.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := dccq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := dccq.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := dccq.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := dccq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (dccq *DailyCategoryContentQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(dccq.driver.Dialect())
|
||||
t1 := builder.Table(dailycategorycontent.Table)
|
||||
columns := dccq.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = dailycategorycontent.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if dccq.sql != nil {
|
||||
selector = dccq.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if dccq.ctx.Unique != nil && *dccq.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range dccq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range dccq.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := dccq.ctx.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 := dccq.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// DailyCategoryContentGroupBy is the group-by builder for DailyCategoryContent entities.
|
||||
type DailyCategoryContentGroupBy struct {
|
||||
selector
|
||||
build *DailyCategoryContentQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (dccgb *DailyCategoryContentGroupBy) Aggregate(fns ...AggregateFunc) *DailyCategoryContentGroupBy {
|
||||
dccgb.fns = append(dccgb.fns, fns...)
|
||||
return dccgb
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (dccgb *DailyCategoryContentGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, dccgb.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := dccgb.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*DailyCategoryContentQuery, *DailyCategoryContentGroupBy](ctx, dccgb.build, dccgb, dccgb.build.inters, v)
|
||||
}
|
||||
|
||||
func (dccgb *DailyCategoryContentGroupBy) sqlScan(ctx context.Context, root *DailyCategoryContentQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(dccgb.fns))
|
||||
for _, fn := range dccgb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*dccgb.flds)+len(dccgb.fns))
|
||||
for _, f := range *dccgb.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*dccgb.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := dccgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// DailyCategoryContentSelect is the builder for selecting fields of DailyCategoryContent entities.
|
||||
type DailyCategoryContentSelect struct {
|
||||
*DailyCategoryContentQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (dccs *DailyCategoryContentSelect) Aggregate(fns ...AggregateFunc) *DailyCategoryContentSelect {
|
||||
dccs.fns = append(dccs.fns, fns...)
|
||||
return dccs
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (dccs *DailyCategoryContentSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, dccs.ctx, ent.OpQuerySelect)
|
||||
if err := dccs.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*DailyCategoryContentQuery, *DailyCategoryContentSelect](ctx, dccs.DailyCategoryContentQuery, dccs, dccs.inters, v)
|
||||
}
|
||||
|
||||
func (dccs *DailyCategoryContentSelect) sqlScan(ctx context.Context, root *DailyCategoryContentQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(dccs.fns))
|
||||
for _, fn := range dccs.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*dccs.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
selector.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := dccs.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue