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

Method First

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

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

(ctx context.Context)

Source from the content-addressed store, hash-verified

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

Callers 1

FirstXMethod · 0.95

Calls 3

LimitMethod · 0.95
setContextOpFunction · 0.85
AllMethod · 0.45

Tested by

no test coverage detected