First returns the first User entity from the query. Returns a *NotFoundError when no User was found.
(ctx context.Context)
| 277 | // First returns the first User entity from the query. |
| 278 | // Returns a *NotFoundError when no User was found. |
| 279 | func (uq *UserQuery) First(ctx context.Context) (*User, error) { |
| 280 | nodes, err := uq.Limit(1).All(setContextOp(ctx, uq.ctx, "First")) |
| 281 | if err != nil { |
| 282 | return nil, err |
| 283 | } |
| 284 | if len(nodes) == 0 { |
| 285 | return nil, &NotFoundError{user.Label} |
| 286 | } |
| 287 | return nodes[0], nil |
| 288 | } |
| 289 | |
| 290 | // FirstX is like First, but panics if an error occurs. |
| 291 | func (uq *UserQuery) FirstX(ctx context.Context) *User { |
no test coverage detected