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

Method FirstID

ent/entity_query.go:157–167  ·  view source on GitHub ↗

FirstID returns the first Entity ID from the query. Returns a *NotFoundError when no Entity ID was found.

(ctx context.Context)

Source from the content-addressed store, hash-verified

155// FirstID returns the first Entity ID from the query.
156// Returns a *NotFoundError when no Entity ID was found.
157func (eq *EntityQuery) FirstID(ctx context.Context) (id int, err error) {
158 var ids []int
159 if ids, err = eq.Limit(1).IDs(setContextOp(ctx, eq.ctx, "FirstID")); err != nil {
160 return
161 }
162 if len(ids) == 0 {
163 err = &NotFoundError{entity.Label}
164 return
165 }
166 return ids[0], nil
167}
168
169// FirstIDX is like FirstID, but panics if an error occurs.
170func (eq *EntityQuery) FirstIDX(ctx context.Context) int {

Callers 2

FirstIDXMethod · 0.95
ExistMethod · 0.95

Calls 3

LimitMethod · 0.95
setContextOpFunction · 0.85
IDsMethod · 0.45

Tested by

no test coverage detected