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

Method First

ent/group_query.go:111–120  ·  view source on GitHub ↗

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

(ctx context.Context)

Source from the content-addressed store, hash-verified

109// First returns the first Group entity from the query.
110// Returns a *NotFoundError when no Group was found.
111func (gq *GroupQuery) First(ctx context.Context) (*Group, error) {
112 nodes, err := gq.Limit(1).All(setContextOp(ctx, gq.ctx, "First"))
113 if err != nil {
114 return nil, err
115 }
116 if len(nodes) == 0 {
117 return nil, &NotFoundError{group.Label}
118 }
119 return nodes[0], nil
120}
121
122// FirstX is like First, but panics if an error occurs.
123func (gq *GroupQuery) FirstX(ctx context.Context) *Group {

Callers 1

FirstXMethod · 0.95

Calls 3

LimitMethod · 0.95
setContextOpFunction · 0.85
AllMethod · 0.45

Tested by

no test coverage detected