MCPcopy
hub / github.com/dgraph-io/dgraph / ToDeletePredEdge

Method ToDeletePredEdge

dql/mutation.go:146–166  ·  view source on GitHub ↗

ToDeletePredEdge takes an NQuad of the form '* p *' and returns the equivalent directed edge. Returns an error if the NQuad does not have the expected form.

()

Source from the content-addressed store, hash-verified

144// ToDeletePredEdge takes an NQuad of the form '* p *' and returns the equivalent
145// directed edge. Returns an error if the NQuad does not have the expected form.
146func (nq NQuad) ToDeletePredEdge() (*pb.DirectedEdge, error) {
147 if nq.Subject != x.Star && nq.ObjectValue.String() != x.Star {
148 return &emptyEdge, errors.Errorf("Subject and object both should be *. Got: %+v", nq)
149 }
150
151 out := &pb.DirectedEdge{
152 // This along with edge.ObjectValue == x.Star would indicate
153 // that we want to delete the predicate.
154 Entity: 0,
155 Attr: nq.Predicate,
156 Namespace: nq.Namespace,
157 Lang: nq.Lang,
158 Facets: nq.Facets,
159 Op: pb.DirectedEdge_DEL,
160 }
161
162 if err := copyValue(out, nq); err != nil {
163 return &emptyEdge, err
164 }
165 return out, nil
166}
167
168// ToEdgeUsing determines the UIDs for the provided XIDs and populates the
169// xidToUid map.

Callers 1

alterMethod · 0.95

Calls 3

copyValueFunction · 0.85
StringMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected