MCPcopy Index your code
hub / github.com/ent/ent / orderByAgg

Function orderByAgg

dialect/sql/sql.go:373–393  ·  view source on GitHub ↗

orderByAgg returns an ordering by the aggregation of the given field.

(fn, field string, opts ...OrderTermOption)

Source from the content-addressed store, hash-verified

371
372// orderByAgg returns an ordering by the aggregation of the given field.
373func orderByAgg(fn, field string, opts ...OrderTermOption) *OrderExprTerm {
374 return &OrderExprTerm{
375 OrderTermOptions: *NewOrderTermOptions(
376 append(
377 // Default alias is "<func>_<field>".
378 []OrderTermOption{OrderAs(fmt.Sprintf("%s_%s", strings.ToLower(fn), field))},
379 opts...,
380 )...,
381 ),
382 Expr: func(s *Selector) Querier {
383 var c string
384 switch {
385 case field == "*", isFunc(field):
386 c = field
387 default:
388 c = s.C(field)
389 }
390 return Raw(fmt.Sprintf("%s(%s)", fn, c))
391 },
392 }
393}
394
395// OrderByRand returns a term to natively order by a random value.
396func OrderByRand() func(*Selector) {

Callers 2

OrderBySumFunction · 0.85
OrderByCountFunction · 0.85

Calls 5

NewOrderTermOptionsFunction · 0.85
OrderAsFunction · 0.85
isFuncFunction · 0.85
RawFunction · 0.85
CMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…