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

Method First

ent/setting_query.go:62–71  ·  view source on GitHub ↗

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

(ctx context.Context)

Source from the content-addressed store, hash-verified

60// First returns the first Setting entity from the query.
61// Returns a *NotFoundError when no Setting was found.
62func (sq *SettingQuery) First(ctx context.Context) (*Setting, error) {
63 nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First"))
64 if err != nil {
65 return nil, err
66 }
67 if len(nodes) == 0 {
68 return nil, &NotFoundError{setting.Label}
69 }
70 return nodes[0], nil
71}
72
73// FirstX is like First, but panics if an error occurs.
74func (sq *SettingQuery) FirstX(ctx context.Context) *Setting {

Callers 1

FirstXMethod · 0.95

Calls 3

LimitMethod · 0.95
setContextOpFunction · 0.85
AllMethod · 0.45

Tested by

no test coverage detected