MCPcopy
hub / github.com/ent/ent / DeleteNodes

Function DeleteNodes

dialect/sql/sqlgraph/graph.go:886–906  ·  view source on GitHub ↗

DeleteNodes applies the DeleteSpec on the graph.

(ctx context.Context, drv dialect.Driver, spec *DeleteSpec)

Source from the content-addressed store, hash-verified

884
885// DeleteNodes applies the DeleteSpec on the graph.
886func DeleteNodes(ctx context.Context, drv dialect.Driver, spec *DeleteSpec) (int, error) {
887 var (
888 res sql.Result
889 builder = sql.Dialect(drv.Dialect())
890 )
891 selector := builder.Select().
892 From(builder.Table(spec.Node.Table).Schema(spec.Node.Schema)).
893 WithContext(ctx)
894 if pred := spec.Predicate; pred != nil {
895 pred(selector)
896 }
897 query, args := builder.Delete(spec.Node.Table).Schema(spec.Node.Schema).FromSelect(selector).Query()
898 if err := drv.Exec(ctx, query, args, &res); err != nil {
899 return 0, err
900 }
901 affected, err := res.RowsAffected()
902 if err != nil {
903 return 0, err
904 }
905 return int(affected), nil
906}
907
908// QuerySpec holds the information for querying
909// nodes in the graph.

Callers 15

sqlExecMethod · 0.92
sqlExecMethod · 0.92
sqlExecMethod · 0.92
sqlExecMethod · 0.92
sqlExecMethod · 0.92
sqlExecMethod · 0.92
sqlExecMethod · 0.92
sqlExecMethod · 0.92
sqlExecMethod · 0.92
sqlExecMethod · 0.92
sqlExecMethod · 0.92
sqlExecMethod · 0.92

Calls 12

DialectFunction · 0.92
WithContextMethod · 0.80
RowsAffectedMethod · 0.80
DialectMethod · 0.65
QueryMethod · 0.65
ExecMethod · 0.65
FromMethod · 0.45
SelectMethod · 0.45
SchemaMethod · 0.45
TableMethod · 0.45
FromSelectMethod · 0.45
DeleteMethod · 0.45

Tested by 2

TestDeleteNodesFunction · 0.68
TestDeleteNodesSchemaFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…