First returns the first Machine entity from the query. Returns a *NotFoundError when no Machine was found.
(ctx context.Context)
| 86 | // First returns the first Machine entity from the query. |
| 87 | // Returns a *NotFoundError when no Machine was found. |
| 88 | func (_q *MachineQuery) First(ctx context.Context) (*Machine, error) { |
| 89 | nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) |
| 90 | if err != nil { |
| 91 | return nil, err |
| 92 | } |
| 93 | if len(nodes) == 0 { |
| 94 | return nil, &NotFoundError{machine.Label} |
| 95 | } |
| 96 | return nodes[0], nil |
| 97 | } |
| 98 | |
| 99 | // FirstX is like First, but panics if an error occurs. |
| 100 | func (_q *MachineQuery) FirstX(ctx context.Context) *Machine { |
no test coverage detected