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 { CreatedAt time.Time `json:"created_at,omitempty"` } client.Machine.Query(). Select(machine.FieldCreatedAt). Scan(ctx, &v)
(fields ...string)
| 329 | // Select(machine.FieldCreatedAt). |
| 330 | // Scan(ctx, &v) |
| 331 | func (_q *MachineQuery) Select(fields ...string) *MachineSelect { |
| 332 | _q.ctx.Fields = append(_q.ctx.Fields, fields...) |
| 333 | sbuild := &MachineSelect{MachineQuery: _q} |
| 334 | sbuild.label = machine.Label |
| 335 | sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan |
| 336 | return sbuild |
| 337 | } |
| 338 | |
| 339 | // Aggregate returns a MachineSelect configured with the given aggregations. |
| 340 | func (_q *MachineQuery) Aggregate(fns ...AggregateFunc) *MachineSelect { |