MCPcopy Create free account
hub / github.com/crowdsecurity/crowdsec / FirstID

Method FirstID

pkg/database/ent/alert_query.go:183–193  ·  view source on GitHub ↗

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

(ctx context.Context)

Source from the content-addressed store, hash-verified

181// FirstID returns the first Alert ID from the query.
182// Returns a *NotFoundError when no Alert ID was found.
183func (_q *AlertQuery) FirstID(ctx context.Context) (id int, err error) {
184 var ids []int
185 if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
186 return
187 }
188 if len(ids) == 0 {
189 err = &NotFoundError{alert.Label}
190 return
191 }
192 return ids[0], nil
193}
194
195// FirstIDX is like FirstID, but panics if an error occurs.
196func (_q *AlertQuery) 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