MCPcopy
hub / github.com/crowdsecurity/crowdsec / FirstID

Method FirstID

pkg/database/ent/meta_query.go:109–119  ·  view source on GitHub ↗

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

(ctx context.Context)

Source from the content-addressed store, hash-verified

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