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

Method First

ent/entity_query.go:135–144  ·  view source on GitHub ↗

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

(ctx context.Context)

Source from the content-addressed store, hash-verified

133// First returns the first Entity entity from the query.
134// Returns a *NotFoundError when no Entity was found.
135func (eq *EntityQuery) First(ctx context.Context) (*Entity, error) {
136 nodes, err := eq.Limit(1).All(setContextOp(ctx, eq.ctx, "First"))
137 if err != nil {
138 return nil, err
139 }
140 if len(nodes) == 0 {
141 return nil, &NotFoundError{entity.Label}
142 }
143 return nodes[0], nil
144}
145
146// FirstX is like First, but panics if an error occurs.
147func (eq *EntityQuery) FirstX(ctx context.Context) *Entity {

Callers 1

FirstXMethod · 0.95

Calls 3

LimitMethod · 0.95
setContextOpFunction · 0.85
AllMethod · 0.45

Tested by

no test coverage detected