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

Method First

ent/user_query.go:279–288  ·  view source on GitHub ↗

First returns the first User entity from the query. Returns a *NotFoundError when no User was found.

(ctx context.Context)

Source from the content-addressed store, hash-verified

277// First returns the first User entity from the query.
278// Returns a *NotFoundError when no User was found.
279func (uq *UserQuery) First(ctx context.Context) (*User, error) {
280 nodes, err := uq.Limit(1).All(setContextOp(ctx, uq.ctx, "First"))
281 if err != nil {
282 return nil, err
283 }
284 if len(nodes) == 0 {
285 return nil, &NotFoundError{user.Label}
286 }
287 return nodes[0], nil
288}
289
290// FirstX is like First, but panics if an error occurs.
291func (uq *UserQuery) FirstX(ctx context.Context) *User {

Callers 1

FirstXMethod · 0.95

Calls 3

LimitMethod · 0.95
setContextOpFunction · 0.85
AllMethod · 0.45

Tested by

no test coverage detected