MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / OnlyID

Method OnlyID

app/controlplane/pkg/data/ent/user_query.go:188–202  ·  view source on GitHub ↗

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

(ctx context.Context)

Source from the content-addressed store, hash-verified

186// Returns a *NotSingularError when more than one User ID is found.
187// Returns a *NotFoundError when no entities are found.
188func (_q *UserQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
189 var ids []uuid.UUID
190 if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
191 return
192 }
193 switch len(ids) {
194 case 1:
195 id = ids[0]
196 case 0:
197 err = &NotFoundError{user.Label}
198 default:
199 err = &NotSingularError{user.Label}
200 }
201 return
202}
203
204// OnlyIDX is like OnlyID, but panics if an error occurs.
205func (_q *UserQuery) OnlyIDX(ctx context.Context) uuid.UUID {

Callers 2

OnlyIDXMethod · 0.95
FindByIDMethod · 0.45

Calls 3

LimitMethod · 0.95
setContextOpFunction · 0.85
IDsMethod · 0.45

Tested by

no test coverage detected