mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
Summary: Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1455 Reviewed By: alexsn Differential Revision: D17396880 fbshipit-source-id: 3a3a9849b816777bd0ef94cf55b2291705a37df6
28 lines
825 B
Cheetah
28 lines
825 B
Cheetah
{{/*
|
|
Copyright 2019-present Facebook Inc. All rights reserved.
|
|
This source code is licensed under the Apache 2.0 license found
|
|
in the LICENSE file in the root directory of this source tree.
|
|
*/}}
|
|
|
|
{{ define "dialect/gremlin/delete" }}
|
|
{{ $builder := pascal $.Scope.Builder }}
|
|
{{ $receiver := receiver $builder }}
|
|
|
|
func ({{ $receiver}} *{{ $builder }}) gremlinExec(ctx context.Context) (int, error) {
|
|
res := &gremlin.Response{}
|
|
query, bindings := {{ $receiver }}.gremlin().Query()
|
|
if err := {{ $receiver }}.driver.Exec(ctx, query, bindings, res); err != nil {
|
|
return 0, err
|
|
}
|
|
return res.ReadInt()
|
|
}
|
|
|
|
|
|
func ({{ $receiver }} *{{ $builder }}) gremlin() *dsl.Traversal {
|
|
t := g.V().HasLabel({{ $.Package }}.Label)
|
|
for _, p := range {{ $receiver }}.predicates {
|
|
p(t)
|
|
}
|
|
return t.SideEffect(__.Drop()).Count()
|
|
}
|
|
{{ end }} |