First returns the first Share entity from the query. Returns a *NotFoundError when no Share was found.
(ctx context.Context)
| 109 | // First returns the first Share entity from the query. |
| 110 | // Returns a *NotFoundError when no Share was found. |
| 111 | func (sq *ShareQuery) First(ctx context.Context) (*Share, error) { |
| 112 | nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First")) |
| 113 | if err != nil { |
| 114 | return nil, err |
| 115 | } |
| 116 | if len(nodes) == 0 { |
| 117 | return nil, &NotFoundError{share.Label} |
| 118 | } |
| 119 | return nodes[0], nil |
| 120 | } |
| 121 | |
| 122 | // FirstX is like First, but panics if an error occurs. |
| 123 | func (sq *ShareQuery) FirstX(ctx context.Context) *Share { |
no test coverage detected