(ctx context.Context, args *ListNodeParameters)
| 73 | } |
| 74 | |
| 75 | func (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 | |
| 104 | func (c *nodeClient) Upsert(ctx context.Context, n *ent.Node) (*ent.Node, error) { |
| 105 | if n.ID == 0 { |
nothing calls this directly
no test coverage detected