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

Method First

ent/storagepolicy_query.go:159–168  ·  view source on GitHub ↗

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

(ctx context.Context)

Source from the content-addressed store, hash-verified

157// First returns the first StoragePolicy entity from the query.
158// Returns a *NotFoundError when no StoragePolicy was found.
159func (spq *StoragePolicyQuery) First(ctx context.Context) (*StoragePolicy, error) {
160 nodes, err := spq.Limit(1).All(setContextOp(ctx, spq.ctx, "First"))
161 if err != nil {
162 return nil, err
163 }
164 if len(nodes) == 0 {
165 return nil, &NotFoundError{storagepolicy.Label}
166 }
167 return nodes[0], nil
168}
169
170// FirstX is like First, but panics if an error occurs.
171func (spq *StoragePolicyQuery) FirstX(ctx context.Context) *StoragePolicy {

Callers 1

FirstXMethod · 0.95

Calls 3

LimitMethod · 0.95
setContextOpFunction · 0.85
AllMethod · 0.45

Tested by

no test coverage detected