First returns the first Setting entity from the query. Returns a *NotFoundError when no Setting was found.
(ctx context.Context)
| 60 | // First returns the first Setting entity from the query. |
| 61 | // Returns a *NotFoundError when no Setting was found. |
| 62 | func (sq *SettingQuery) First(ctx context.Context) (*Setting, error) { |
| 63 | nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First")) |
| 64 | if err != nil { |
| 65 | return nil, err |
| 66 | } |
| 67 | if len(nodes) == 0 { |
| 68 | return nil, &NotFoundError{setting.Label} |
| 69 | } |
| 70 | return nodes[0], nil |
| 71 | } |
| 72 | |
| 73 | // FirstX is like First, but panics if an error occurs. |
| 74 | func (sq *SettingQuery) FirstX(ctx context.Context) *Setting { |
no test coverage detected