First returns the first User entity from the query. Returns a *NotFoundError when no User was found.
(ctx context.Context)
| 113 | // First returns the first User entity from the query. |
| 114 | // Returns a *NotFoundError when no User was found. |
| 115 | func (_q *UserQuery) First(ctx context.Context) (*User, error) { |
| 116 | nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) |
| 117 | if err != nil { |
| 118 | return nil, err |
| 119 | } |
| 120 | if len(nodes) == 0 { |
| 121 | return nil, &NotFoundError{user.Label} |
| 122 | } |
| 123 | return nodes[0], nil |
| 124 | } |
| 125 | |
| 126 | // FirstX is like First, but panics if an error occurs. |
| 127 | func (_q *UserQuery) FirstX(ctx context.Context) *User { |
no test coverage detected