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

Method OnlyID

ent/node_query.go:211–225  ·  view source on GitHub ↗

OnlyID is like Only, but returns the only Node ID in the query. Returns a *NotSingularError when more than one Node ID is found. Returns a *NotFoundError when no entities are found.

(ctx context.Context)

Source from the content-addressed store, hash-verified

209// Returns a *NotSingularError when more than one Node ID is found.
210// Returns a *NotFoundError when no entities are found.
211func (nq *NodeQuery) OnlyID(ctx context.Context) (id string, err error) {
212 var ids []string
213 if ids, err = nq.Limit(2).IDs(setContextOp(ctx, nq.ctx, ent.OpQueryOnlyID)); err != nil {
214 return
215 }
216 switch len(ids) {
217 case 1:
218 id = ids[0]
219 case 0:
220 err = &NotFoundError{node.Label}
221 default:
222 err = &NotSingularError{node.Label}
223 }
224 return
225}
226
227// OnlyIDX is like OnlyID, but panics if an error occurs.
228func (nq *NodeQuery) OnlyIDX(ctx context.Context) string {

Callers 1

OnlyIDXMethod · 0.95

Calls 3

LimitMethod · 0.95
setContextOpFunction · 0.85
IDsMethod · 0.45

Tested by

no test coverage detected