MCPcopy Create free account
hub / github.com/Comfy-Org/registry-backend / OnlyID

Method OnlyID

ent/nodeversion_query.go:213–227  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

211// Returns a *NotSingularError when more than one NodeVersion ID is found.
212// Returns a *NotFoundError when no entities are found.
213func (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.
230func (nvq *NodeVersionQuery) OnlyIDX(ctx context.Context) uuid.UUID {

Callers 1

OnlyIDXMethod · 0.95

Calls 3

LimitMethod · 0.95
setContextOpFunction · 0.85
IDsMethod · 0.45

Tested by

no test coverage detected