MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / FirstID

Method FirstID

ent/user_query.go:301–311  ·  view source on GitHub ↗

FirstID returns the first User ID from the query. Returns a *NotFoundError when no User ID was found.

(ctx context.Context)

Source from the content-addressed store, hash-verified

299// FirstID returns the first User ID from the query.
300// Returns a *NotFoundError when no User ID was found.
301func (uq *UserQuery) FirstID(ctx context.Context) (id int, err error) {
302 var ids []int
303 if ids, err = uq.Limit(1).IDs(setContextOp(ctx, uq.ctx, "FirstID")); err != nil {
304 return
305 }
306 if len(ids) == 0 {
307 err = &NotFoundError{user.Label}
308 return
309 }
310 return ids[0], nil
311}
312
313// FirstIDX is like FirstID, but panics if an error occurs.
314func (uq *UserQuery) FirstIDX(ctx context.Context) int {

Callers 2

FirstIDXMethod · 0.95
ExistMethod · 0.95

Calls 3

LimitMethod · 0.95
setContextOpFunction · 0.85
IDsMethod · 0.45

Tested by

no test coverage detected