MCPcopy Index your code
hub / github.com/cloudreve/cloudreve / FirstID

Method FirstID

ent/metadata_query.go:108–118  ·  view source on GitHub ↗

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

(ctx context.Context)

Source from the content-addressed store, hash-verified

106// FirstID returns the first Metadata ID from the query.
107// Returns a *NotFoundError when no Metadata ID was found.
108func (mq *MetadataQuery) FirstID(ctx context.Context) (id int, err error) {
109 var ids []int
110 if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil {
111 return
112 }
113 if len(ids) == 0 {
114 err = &NotFoundError{metadata.Label}
115 return
116 }
117 return ids[0], nil
118}
119
120// FirstIDX is like FirstID, but panics if an error occurs.
121func (mq *MetadataQuery) 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