First returns the first File entity from the query. Returns a *NotFoundError when no File was found.
(ctx context.Context)
| 251 | // First returns the first File entity from the query. |
| 252 | // Returns a *NotFoundError when no File was found. |
| 253 | func (fq *FileQuery) First(ctx context.Context) (*File, error) { |
| 254 | nodes, err := fq.Limit(1).All(setContextOp(ctx, fq.ctx, "First")) |
| 255 | if err != nil { |
| 256 | return nil, err |
| 257 | } |
| 258 | if len(nodes) == 0 { |
| 259 | return nil, &NotFoundError{file.Label} |
| 260 | } |
| 261 | return nodes[0], nil |
| 262 | } |
| 263 | |
| 264 | // FirstX is like First, but panics if an error occurs. |
| 265 | func (fq *FileQuery) FirstX(ctx context.Context) *File { |
no test coverage detected