-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathupdate.go
96 lines (88 loc) · 2.5 KB
/
update.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package db
import (
"github.com/rlch/neogo/internal"
"github.com/rlch/neogo/query"
)
// SetPropValue sets a property to a value in a [SET] clause.
//
// SET <identifier> = <value>
//
// [SET]: https://neo4j.com/docs/cypher-manual/current/clauses/set/
func SetPropValue(identifier query.PropertyIdentifier, value query.ValueIdentifier) internal.SetItem {
return internal.SetItem{
PropIdentifier: identifier,
ValIdentifier: value,
}
}
// SetMerge merges a property to a value in a [SET] clause.
//
// SET <identifier> += <properties>
//
// [SET]: https://neo4j.com/docs/cypher-manual/current/clauses/set/
func SetMerge(identifier query.PropertyIdentifier, properties any) internal.SetItem {
return internal.SetItem{
PropIdentifier: identifier,
ValIdentifier: properties,
Merge: true,
}
}
// SetLabels sets labels in a [SET] clause.
//
// SET <identifier>:<label>:...:<label>
//
// [SET]: https://neo4j.com/docs/cypher-manual/current/clauses/set/
func SetLabels(identifier query.PropertyIdentifier, labels ...string) internal.SetItem {
return internal.SetItem{
PropIdentifier: identifier,
Labels: labels,
}
}
// RemoveProp removes a property in a [REMOVE] clause.
//
// SET <identifier>.<prop>
//
// [REMOVE]: https://neo4j.com/docs/cypher-manual/current/clauses/remove/
func RemoveProp(identifier query.PropertyIdentifier) internal.RemoveItem {
return internal.RemoveItem{
PropIdentifier: identifier,
}
}
// RemoveLabels removes labels in a [REMOVE] clause.
//
// REMOVE <identifier>:<label>:...:<label>
//
// [REMOVE]: https://neo4j.com/docs/cypher-manual/current/clauses/remove/
func RemoveLabels(identifier query.PropertyIdentifier, labels ...string) internal.RemoveItem {
return internal.RemoveItem{
PropIdentifier: identifier,
Labels: labels,
}
}
// OnCreate sets the actions to perform when a [MERGE] clause creates a node.
//
// ON CREATE
// SET <...>
// ...
//
// [MERGE]: https://neo4j.com/docs/cypher-manual/current/clauses/merge/
func OnCreate(set ...internal.SetItem) internal.MergeOption {
return &internal.Configurer{
Merge: func(mo *internal.Merge) {
mo.OnCreate = append(mo.OnCreate, set...)
},
}
}
// OnMatch sets the actions to perform when a [MERGE] clause matches a node.
//
// ON MATCH
// SET <...>
// ...
//
// [MERGE]: https://neo4j.com/docs/cypher-manual/current/clauses/merge/
func OnMatch(set ...internal.SetItem) internal.MergeOption {
return &internal.Configurer{
Merge: func(mo *internal.Merge) {
mo.OnMatch = append(mo.OnMatch, set...)
},
}
}