FirstID returns the first Metadata ID from the query. Returns a *NotFoundError when no Metadata ID was found.
(ctx context.Context)
| 106 | // FirstID returns the first Metadata ID from the query. |
| 107 | // Returns a *NotFoundError when no Metadata ID was found. |
| 108 | func (mq *MetadataQuery) FirstID(ctx context.Context) (id int, err error) { |
| 109 | var ids []int |
| 110 | if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil { |
| 111 | return |
| 112 | } |
| 113 | if len(ids) == 0 { |
| 114 | err = &NotFoundError{metadata.Label} |
| 115 | return |
| 116 | } |
| 117 | return ids[0], nil |
| 118 | } |
| 119 | |
| 120 | // FirstIDX is like FirstID, but panics if an error occurs. |
| 121 | func (mq *MetadataQuery) FirstIDX(ctx context.Context) int { |
no test coverage detected