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

Method First

pkg/database/ent/alert_query.go:161–170  ·  view source on GitHub ↗

First returns the first Alert entity from the query. Returns a *NotFoundError when no Alert was found.

(ctx context.Context)

Source from the content-addressed store, hash-verified

159// First returns the first Alert entity from the query.
160// Returns a *NotFoundError when no Alert was found.
161func (_q *AlertQuery) First(ctx context.Context) (*Alert, error) {
162 nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
163 if err != nil {
164 return nil, err
165 }
166 if len(nodes) == 0 {
167 return nil, &NotFoundError{alert.Label}
168 }
169 return nodes[0], nil
170}
171
172// FirstX is like First, but panics if an error occurs.
173func (_q *AlertQuery) FirstX(ctx context.Context) *Alert {

Callers 1

FirstXMethod · 0.95

Calls 3

LimitMethod · 0.95
setContextOpFunction · 0.85
AllMethod · 0.45

Tested by

no test coverage detected