OnlyID is like Only, but returns the only NodeVersion ID in the query. Returns a *NotSingularError when more than one NodeVersion ID is found. Returns a *NotFoundError when no entities are found.
(ctx context.Context)
| 211 | // Returns a *NotSingularError when more than one NodeVersion ID is found. |
| 212 | // Returns a *NotFoundError when no entities are found. |
| 213 | func (nvq *NodeVersionQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { |
| 214 | var ids []uuid.UUID |
| 215 | if ids, err = nvq.Limit(2).IDs(setContextOp(ctx, nvq.ctx, ent.OpQueryOnlyID)); err != nil { |
| 216 | return |
| 217 | } |
| 218 | switch len(ids) { |
| 219 | case 1: |
| 220 | id = ids[0] |
| 221 | case 0: |
| 222 | err = &NotFoundError{nodeversion.Label} |
| 223 | default: |
| 224 | err = &NotSingularError{nodeversion.Label} |
| 225 | } |
| 226 | return |
| 227 | } |
| 228 | |
| 229 | // OnlyIDX is like OnlyID, but panics if an error occurs. |
| 230 | func (nvq *NodeVersionQuery) OnlyIDX(ctx context.Context) uuid.UUID { |
no test coverage detected