FirstID returns the first User ID from the query. Returns a *NotFoundError when no User ID was found.
(ctx context.Context)
| 299 | // FirstID returns the first User ID from the query. |
| 300 | // Returns a *NotFoundError when no User ID was found. |
| 301 | func (uq *UserQuery) FirstID(ctx context.Context) (id int, err error) { |
| 302 | var ids []int |
| 303 | if ids, err = uq.Limit(1).IDs(setContextOp(ctx, uq.ctx, "FirstID")); err != nil { |
| 304 | return |
| 305 | } |
| 306 | if len(ids) == 0 { |
| 307 | err = &NotFoundError{user.Label} |
| 308 | return |
| 309 | } |
| 310 | return ids[0], nil |
| 311 | } |
| 312 | |
| 313 | // FirstIDX is like FirstID, but panics if an error occurs. |
| 314 | func (uq *UserQuery) FirstIDX(ctx context.Context) int { |
no test coverage detected