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

Method First

ent/file_query.go:253–262  ·  view source on GitHub ↗

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

(ctx context.Context)

Source from the content-addressed store, hash-verified

251// First returns the first File entity from the query.
252// Returns a *NotFoundError when no File was found.
253func (fq *FileQuery) First(ctx context.Context) (*File, error) {
254 nodes, err := fq.Limit(1).All(setContextOp(ctx, fq.ctx, "First"))
255 if err != nil {
256 return nil, err
257 }
258 if len(nodes) == 0 {
259 return nil, &NotFoundError{file.Label}
260 }
261 return nodes[0], nil
262}
263
264// FirstX is like First, but panics if an error occurs.
265func (fq *FileQuery) FirstX(ctx context.Context) *File {

Callers 1

FirstXMethod · 0.95

Calls 3

LimitMethod · 0.95
setContextOpFunction · 0.85
AllMethod · 0.45

Tested by

no test coverage detected