First returns the first Group entity from the query. Returns a *NotFoundError when no Group was found.
(ctx context.Context)
| 113 | // First returns the first Group entity from the query. |
| 114 | // Returns a *NotFoundError when no Group was found. |
| 115 | func (_q *GroupQuery) First(ctx context.Context) (*Group, 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{group.Label} |
| 122 | } |
| 123 | return nodes[0], nil |
| 124 | } |
| 125 | |
| 126 | // FirstX is like First, but panics if an error occurs. |
| 127 | func (_q *GroupQuery) FirstX(ctx context.Context) *Group { |
no test coverage detected