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

Method First

pkg/database/ent/event_query.go:87–96  ·  view source on GitHub ↗

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

(ctx context.Context)

Source from the content-addressed store, hash-verified

85// First returns the first Event entity from the query.
86// Returns a *NotFoundError when no Event was found.
87func (_q *EventQuery) First(ctx context.Context) (*Event, error) {
88 nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
89 if err != nil {
90 return nil, err
91 }
92 if len(nodes) == 0 {
93 return nil, &NotFoundError{event.Label}
94 }
95 return nodes[0], nil
96}
97
98// FirstX is like First, but panics if an error occurs.
99func (_q *EventQuery) FirstX(ctx context.Context) *Event {

Callers 1

FirstXMethod · 0.95

Calls 3

LimitMethod · 0.95
setContextOpFunction · 0.85
AllMethod · 0.45

Tested by

no test coverage detected