Sum applies the "sum" aggregation function on the given field of each group.
(field string)
| 197 | |
| 198 | // Sum applies the "sum" aggregation function on the given field of each group. |
| 199 | func Sum(field string) AggregateFunc { |
| 200 | return func(s *sql.Selector) string { |
| 201 | if err := checkColumn(s.TableName(), field); err != nil { |
| 202 | s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) |
| 203 | return "" |
| 204 | } |
| 205 | return sql.Sum(s.C(field)) |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | // ValidationError returns when validating a field or edge fails. |
| 210 | type ValidationError struct { |
nothing calls this directly
no test coverage detected