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

Method FirstID

pkg/database/ent/machine_query.go:110–120  ·  view source on GitHub ↗

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

(ctx context.Context)

Source from the content-addressed store, hash-verified

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