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

Method First

ent/directlink_query.go:86–95  ·  view source on GitHub ↗

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

(ctx context.Context)

Source from the content-addressed store, hash-verified

84// First returns the first DirectLink entity from the query.
85// Returns a *NotFoundError when no DirectLink was found.
86func (dlq *DirectLinkQuery) First(ctx context.Context) (*DirectLink, error) {
87 nodes, err := dlq.Limit(1).All(setContextOp(ctx, dlq.ctx, "First"))
88 if err != nil {
89 return nil, err
90 }
91 if len(nodes) == 0 {
92 return nil, &NotFoundError{directlink.Label}
93 }
94 return nodes[0], nil
95}
96
97// FirstX is like First, but panics if an error occurs.
98func (dlq *DirectLinkQuery) FirstX(ctx context.Context) *DirectLink {

Callers 1

FirstXMethod · 0.95

Calls 3

LimitMethod · 0.95
setContextOpFunction · 0.85
AllMethod · 0.45

Tested by

no test coverage detected