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

Method OnlyID

ent/gitcommit_query.go:164–178  ·  view source on GitHub ↗

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

(ctx context.Context)

Source from the content-addressed store, hash-verified

162// Returns a *NotSingularError when more than one GitCommit ID is found.
163// Returns a *NotFoundError when no entities are found.
164func (gcq *GitCommitQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
165 var ids []uuid.UUID
166 if ids, err = gcq.Limit(2).IDs(setContextOp(ctx, gcq.ctx, ent.OpQueryOnlyID)); err != nil {
167 return
168 }
169 switch len(ids) {
170 case 1:
171 id = ids[0]
172 case 0:
173 err = &NotFoundError{gitcommit.Label}
174 default:
175 err = &NotSingularError{gitcommit.Label}
176 }
177 return
178}
179
180// OnlyIDX is like OnlyID, but panics if an error occurs.
181func (gcq *GitCommitQuery) 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