-
Notifications
You must be signed in to change notification settings - Fork 0
/
unions.go
32 lines (28 loc) · 1014 Bytes
/
unions.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
package dal
// arrayUnion is a special type in dalgo. It instructs the server to add its
// elements to whatever array already exists, or to create an array if no value
// exists.
type arrayUnion struct {
elems []any
}
func (arrayUnion) Name() string {
return "ArrayUnion"
}
func (v arrayUnion) Value() any {
return v.elems
}
// ArrayUnion specifies elements to be added to whatever array already exists in
// the server, or to create an array if no value exists.
//
// If a value exists and it's an array, values are appended to it. Any duplicate
// value is ignored.
// If a value exists and it's not an array, the value is replaced by an array of
// the values in the ArrayUnion.
// If a value does not exist, an array of the values in the ArrayUnion is created.
//
// ArrayUnion must be the value of a field directly; it cannot appear in
// array or struct values, or in any value that is itself inside an array or
// struct.
func ArrayUnion(elems ...any) Transform {
return arrayUnion{elems: elems}
}