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

Method Upsert

inventory/node.go:104–132  ·  view source on GitHub ↗
(ctx context.Context, n *ent.Node)

Source from the content-addressed store, hash-verified

102}
103
104func (c *nodeClient) Upsert(ctx context.Context, n *ent.Node) (*ent.Node, error) {
105 if n.ID == 0 {
106 return c.client.Node.Create().
107 SetName(n.Name).
108 SetServer(n.Server).
109 SetSlaveKey(n.SlaveKey).
110 SetStatus(n.Status).
111 SetType(node.TypeSlave).
112 SetSettings(n.Settings).
113 SetCapabilities(n.Capabilities).
114 SetWeight(n.Weight).
115 Save(ctx)
116 }
117
118 res, err := c.client.Node.UpdateOne(n).
119 SetName(n.Name).
120 SetServer(n.Server).
121 SetSlaveKey(n.SlaveKey).
122 SetStatus(n.Status).
123 SetSettings(n.Settings).
124 SetCapabilities(n.Capabilities).
125 SetWeight(n.Weight).
126 Save(ctx)
127 if err != nil {
128 return nil, err
129 }
130
131 return res, nil
132}
133
134func getNodeOrderOption(args *ListNodeParameters) []node.OrderOption {
135 orderTerm := getOrderTerm(args.Order)

Callers

nothing calls this directly

Calls 11

SetStatusMethod · 0.65
CreateMethod · 0.65
SaveMethod · 0.45
SetWeightMethod · 0.45
SetCapabilitiesMethod · 0.45
SetSettingsMethod · 0.45
SetTypeMethod · 0.45
SetSlaveKeyMethod · 0.45
SetServerMethod · 0.45
SetNameMethod · 0.45
UpdateOneMethod · 0.45

Tested by

no test coverage detected