MCPcopy Index your code
hub / github.com/cloudreve/cloudreve / ListNodes

Method ListNodes

inventory/node.go:75–102  ·  view source on GitHub ↗
(ctx context.Context, args *ListNodeParameters)

Source from the content-addressed store, hash-verified

73}
74
75func (c *nodeClient) ListNodes(ctx context.Context, args *ListNodeParameters) (*ListNodeResult, error) {
76 query := c.client.Node.Query()
77 if string(args.Status) != "" {
78 query = query.Where(node.StatusEQ(args.Status))
79 }
80 query.Order(getNodeOrderOption(args)...)
81
82 // Count total items
83 total, err := query.Clone().
84 Count(ctx)
85 if err != nil {
86 return nil, err
87 }
88
89 nodes, err := withNodeEagerLoading(ctx, query).Limit(args.PageSize).Offset(args.Page * args.PageSize).All(ctx)
90 if err != nil {
91 return nil, err
92 }
93
94 return &ListNodeResult{
95 PaginationResults: &PaginationResults{
96 TotalItems: total,
97 Page: args.Page,
98 PageSize: args.PageSize,
99 },
100 Nodes: nodes,
101 }, nil
102}
103
104func (c *nodeClient) Upsert(ctx context.Context, n *ent.Node) (*ent.Node, error) {
105 if n.ID == 0 {

Callers

nothing calls this directly

Calls 11

StatusEQFunction · 0.92
getNodeOrderOptionFunction · 0.85
withNodeEagerLoadingFunction · 0.85
OrderMethod · 0.65
CountMethod · 0.65
OffsetMethod · 0.65
LimitMethod · 0.65
QueryMethod · 0.45
WhereMethod · 0.45
CloneMethod · 0.45
AllMethod · 0.45

Tested by

no test coverage detected