mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: add inc/dec capability for numeric fields
Reviewed By: alexsn Differential Revision: D17259987 fbshipit-source-id: ad5ba1ba7383418463bc9137d82f16eadef809e7
This commit is contained in:
committed by
Facebook Github Bot
parent
b59fb59b9a
commit
d820361a3a
@@ -51,6 +51,12 @@ func OutV(args ...interface{}) *dsl.Traversal { return New().OutV(args...) }
|
||||
// Values is the api for calling __.Values().
|
||||
func Values(args ...string) *dsl.Traversal { return New().Values(args...) }
|
||||
|
||||
// Union is the api for calling __.Union().
|
||||
func Union(args ...interface{}) *dsl.Traversal { return New().Union(args...) }
|
||||
|
||||
// Constant is the api for calling __.Constant().
|
||||
func Constant(args ...interface{}) *dsl.Traversal { return New().Constant(args...) }
|
||||
|
||||
// OtherV is the api for calling __.OtherV().
|
||||
func OtherV() *dsl.Traversal { return New().OtherV() }
|
||||
|
||||
|
||||
@@ -216,6 +216,11 @@ func TestTraverse(t *testing.T) {
|
||||
wantQuery: "g.V().has($0, $1, $2).count().coalesce(__.is(neq($3)).constant($4), g.addV($5).property($6, $7).valueMap($8))",
|
||||
wantBinds: dsl.Bindings{"$0": "person", "$1": "name", "$2": "a8m", "$3": 0, "$4": "unique constraint failed", "$5": "person", "$6": "name", "$7": "a8m", "$8": true},
|
||||
},
|
||||
{
|
||||
input: g.V().Has("age").Property("age", __.Union(__.Values("age"), __.Constant(10)).Sum()).ValueMap(),
|
||||
wantQuery: "g.V().has($0).property($1, __.union(__.values($2), __.constant($3)).sum()).valueMap()",
|
||||
wantBinds: dsl.Bindings{"$0": "age", "$1": "age", "$2": "age", "$3": 10},
|
||||
},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
tt := tt
|
||||
|
||||
@@ -334,6 +334,11 @@ func (t *Traversal) Constant(args ...interface{}) *Traversal {
|
||||
return t.Add(Dot, NewFunc("constant", args...))
|
||||
}
|
||||
|
||||
// Union merges the results of an arbitrary number of traversals.
|
||||
func (t *Traversal) Union(args ...interface{}) *Traversal {
|
||||
return t.Add(Dot, NewFunc("union", args...))
|
||||
}
|
||||
|
||||
// Each is a Groovy each-loop function.
|
||||
func Each(v interface{}, cb func(it *Traversal) *Traversal) *Traversal {
|
||||
t := &Traversal{}
|
||||
|
||||
Reference in New Issue
Block a user