First returns the first Alert entity from the query. Returns a *NotFoundError when no Alert was found.
(ctx context.Context)
| 159 | // First returns the first Alert entity from the query. |
| 160 | // Returns a *NotFoundError when no Alert was found. |
| 161 | func (_q *AlertQuery) First(ctx context.Context) (*Alert, error) { |
| 162 | nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) |
| 163 | if err != nil { |
| 164 | return nil, err |
| 165 | } |
| 166 | if len(nodes) == 0 { |
| 167 | return nil, &NotFoundError{alert.Label} |
| 168 | } |
| 169 | return nodes[0], nil |
| 170 | } |
| 171 | |
| 172 | // FirstX is like First, but panics if an error occurs. |
| 173 | func (_q *AlertQuery) FirstX(ctx context.Context) *Alert { |
no test coverage detected