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 { CreatedAt time.Time `json:"created_at,omitempty"` Count int `json:"count,omitempty"` } client.Metadata.Query(). GroupBy(
(field string, fields ...string)
| 306 | // Aggregate(ent.Count()). |
| 307 | // Scan(ctx, &v) |
| 308 | func (mq *MetadataQuery) GroupBy(field string, fields ...string) *MetadataGroupBy { |
| 309 | mq.ctx.Fields = append([]string{field}, fields...) |
| 310 | grbuild := &MetadataGroupBy{build: mq} |
| 311 | grbuild.flds = &mq.ctx.Fields |
| 312 | grbuild.label = metadata.Label |
| 313 | grbuild.scan = grbuild.Scan |
| 314 | return grbuild |
| 315 | } |
| 316 | |
| 317 | // Select allows the selection one or more fields/columns for the given query, |
| 318 | // instead of selecting all fields in the entity. |