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

Method sqlAll

pkg/database/ent/event_query.go:369–402  ·  view source on GitHub ↗
(ctx context.Context, hooks ...queryHook)

Source from the content-addressed store, hash-verified

367}
368
369func (_q *EventQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Event, error) {
370 var (
371 nodes = []*Event{}
372 _spec = _q.querySpec()
373 loadedTypes = [1]bool{
374 _q.withOwner != nil,
375 }
376 )
377 _spec.ScanValues = func(columns []string) ([]any, error) {
378 return (*Event).scanValues(nil, columns)
379 }
380 _spec.Assign = func(columns []string, values []any) error {
381 node := &Event{config: _q.config}
382 nodes = append(nodes, node)
383 node.Edges.loadedTypes = loadedTypes
384 return node.assignValues(columns, values)
385 }
386 for i := range hooks {
387 hooks[i](ctx, _spec)
388 }
389 if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
390 return nil, err
391 }
392 if len(nodes) == 0 {
393 return nodes, nil
394 }
395 if query := _q.withOwner; query != nil {
396 if err := _q.loadOwner(ctx, query, nodes, nil,
397 func(n *Event, e *Alert) { n.Edges.Owner = e }); err != nil {
398 return nil, err
399 }
400 }
401 return nodes, nil
402}
403
404func (_q *EventQuery) loadOwner(ctx context.Context, query *AlertQuery, nodes []*Event, init func(*Event), assign func(*Event, *Alert)) error {
405 ids := make([]int, 0, len(nodes))

Callers

nothing calls this directly

Calls 4

querySpecMethod · 0.95
assignValuesMethod · 0.95
loadOwnerMethod · 0.95
scanValuesMethod · 0.45

Tested by

no test coverage detected