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

Method First

pkg/database/ent/machine_query.go:88–97  ·  view source on GitHub ↗

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

(ctx context.Context)

Source from the content-addressed store, hash-verified

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

Callers 1

FirstXMethod · 0.95

Calls 3

LimitMethod · 0.95
setContextOpFunction · 0.85
AllMethod · 0.45

Tested by

no test coverage detected