forked from fl00r/go-tarantool-1.6
-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathupsert_many.go
141 lines (118 loc) · 4.42 KB
/
upsert_many.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package crud
import (
"context"
"github.com/vmihailenco/msgpack/v5"
"github.com/tarantool/go-tarantool/v2"
)
// UpsertManyOpts describes options for `crud.upsert_many` method.
type UpsertManyOpts = OperationManyOpts
// TupleOperationsData contains tuple with operations to be applied to tuple.
type TupleOperationsData struct {
_msgpack struct{} `msgpack:",asArray"` //nolint: structcheck,unused
Tuple Tuple
Operations []Operation
}
// UpsertManyRequest helps you to create request object to call
// `crud.upsert_many` for execution by a Connection.
type UpsertManyRequest struct {
spaceRequest
tuplesOperationsData []TupleOperationsData
opts UpsertManyOpts
}
type upsertManyArgs struct {
_msgpack struct{} `msgpack:",asArray"` //nolint: structcheck,unused
Space string
TuplesOperationsData []TupleOperationsData
Opts UpsertManyOpts
}
// MakeUpsertManyRequest returns a new empty UpsertManyRequest.
func MakeUpsertManyRequest(space string) UpsertManyRequest {
req := UpsertManyRequest{}
req.impl = newCall("crud.upsert_many")
req.space = space
req.tuplesOperationsData = []TupleOperationsData{}
req.opts = UpsertManyOpts{}
return req
}
// TuplesOperationsData sets tuples and operations for
// the UpsertManyRequest request.
// Note: default value is nil.
func (req UpsertManyRequest) TuplesOperationsData(
tuplesOperationData []TupleOperationsData) UpsertManyRequest {
req.tuplesOperationsData = tuplesOperationData
return req
}
// Opts sets the options for the UpsertManyRequest request.
// Note: default value is nil.
func (req UpsertManyRequest) Opts(opts UpsertManyOpts) UpsertManyRequest {
req.opts = opts
return req
}
// Body fills an encoder with the call request body.
func (req UpsertManyRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error {
args := upsertManyArgs{Space: req.space, TuplesOperationsData: req.tuplesOperationsData,
Opts: req.opts}
req.impl = req.impl.Args(args)
return req.impl.Body(res, enc)
}
// Context sets a passed context to CRUD request.
func (req UpsertManyRequest) Context(ctx context.Context) UpsertManyRequest {
req.impl = req.impl.Context(ctx)
return req
}
// UpsertObjectManyOpts describes options for `crud.upsert_object_many` method.
type UpsertObjectManyOpts = OperationManyOpts
// ObjectOperationsData contains object with operations to be applied to object.
type ObjectOperationsData struct {
_msgpack struct{} `msgpack:",asArray"` //nolint: structcheck,unused
Object Object
Operations []Operation
}
// UpsertObjectManyRequest helps you to create request object to call
// `crud.upsert_object_many` for execution by a Connection.
type UpsertObjectManyRequest struct {
spaceRequest
objectsOperationsData []ObjectOperationsData
opts UpsertObjectManyOpts
}
type upsertObjectManyArgs struct {
_msgpack struct{} `msgpack:",asArray"` //nolint: structcheck,unused
Space string
ObjectsOperationsData []ObjectOperationsData
Opts UpsertObjectManyOpts
}
// MakeUpsertObjectManyRequest returns a new empty UpsertObjectManyRequest.
func MakeUpsertObjectManyRequest(space string) UpsertObjectManyRequest {
req := UpsertObjectManyRequest{}
req.impl = newCall("crud.upsert_object_many")
req.space = space
req.objectsOperationsData = []ObjectOperationsData{}
req.opts = UpsertObjectManyOpts{}
return req
}
// ObjectOperationsData sets objects and operations
// for the UpsertObjectManyRequest request.
// Note: default value is nil.
func (req UpsertObjectManyRequest) ObjectsOperationsData(
objectsOperationData []ObjectOperationsData) UpsertObjectManyRequest {
req.objectsOperationsData = objectsOperationData
return req
}
// Opts sets the options for the UpsertObjectManyRequest request.
// Note: default value is nil.
func (req UpsertObjectManyRequest) Opts(opts UpsertObjectManyOpts) UpsertObjectManyRequest {
req.opts = opts
return req
}
// Body fills an encoder with the call request body.
func (req UpsertObjectManyRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error {
args := upsertObjectManyArgs{Space: req.space, ObjectsOperationsData: req.objectsOperationsData,
Opts: req.opts}
req.impl = req.impl.Args(args)
return req.impl.Body(res, enc)
}
// Context sets a passed context to CRUD request.
func (req UpsertObjectManyRequest) Context(ctx context.Context) UpsertObjectManyRequest {
req.impl = req.impl.Context(ctx)
return req
}