FirstID returns the first Machine ID from the query. Returns a *NotFoundError when no Machine ID was found.
(ctx context.Context)
| 108 | // FirstID returns the first Machine ID from the query. |
| 109 | // Returns a *NotFoundError when no Machine ID was found. |
| 110 | func (_q *MachineQuery) FirstID(ctx context.Context) (id int, err error) { |
| 111 | var ids []int |
| 112 | if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { |
| 113 | return |
| 114 | } |
| 115 | if len(ids) == 0 { |
| 116 | err = &NotFoundError{machine.Label} |
| 117 | return |
| 118 | } |
| 119 | return ids[0], nil |
| 120 | } |
| 121 | |
| 122 | // FirstIDX is like FirstID, but panics if an error occurs. |
| 123 | func (_q *MachineQuery) FirstIDX(ctx context.Context) int { |
no test coverage detected