FirstID returns the first Entity ID from the query. Returns a *NotFoundError when no Entity ID was found.
(ctx context.Context)
| 155 | // FirstID returns the first Entity ID from the query. |
| 156 | // Returns a *NotFoundError when no Entity ID was found. |
| 157 | func (eq *EntityQuery) FirstID(ctx context.Context) (id int, err error) { |
| 158 | var ids []int |
| 159 | if ids, err = eq.Limit(1).IDs(setContextOp(ctx, eq.ctx, "FirstID")); err != nil { |
| 160 | return |
| 161 | } |
| 162 | if len(ids) == 0 { |
| 163 | err = &NotFoundError{entity.Label} |
| 164 | return |
| 165 | } |
| 166 | return ids[0], nil |
| 167 | } |
| 168 | |
| 169 | // FirstIDX is like FirstID, but panics if an error occurs. |
| 170 | func (eq *EntityQuery) FirstIDX(ctx context.Context) int { |
no test coverage detected