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

Method FirstID

ent/share_query.go:133–143  ·  view source on GitHub ↗

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

(ctx context.Context)

Source from the content-addressed store, hash-verified

131// FirstID returns the first Share ID from the query.
132// Returns a *NotFoundError when no Share ID was found.
133func (sq *ShareQuery) FirstID(ctx context.Context) (id int, err error) {
134 var ids []int
135 if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, "FirstID")); err != nil {
136 return
137 }
138 if len(ids) == 0 {
139 err = &NotFoundError{share.Label}
140 return
141 }
142 return ids[0], nil
143}
144
145// FirstIDX is like FirstID, but panics if an error occurs.
146func (sq *ShareQuery) 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