-
Notifications
You must be signed in to change notification settings - Fork 247
/
IMutateInBuilder.cs
368 lines (325 loc) · 22.7 KB
/
IMutateInBuilder.cs
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
using System;
using Couchbase.KeyValue;
namespace Couchbase.Core.IO.Operations.SubDocument
{
/// <summary>
/// Exposes the creation of a set of mutation operations to be performed.
/// </summary>
/// <typeparam name="TDocument">The strong typed document (POCO) reflecting the structure of the paths.</typeparam>
[Obsolete("This interface is not required and will be removed in a future release.")] // Delete
public interface IMutateInBuilder<TDocument> : ISubDocBuilder<TDocument>
{
/// <summary>
/// A "check-and-set" value for ensuring that a document has not been modified by another thread.
/// </summary>
ulong Cas { get; }
/// <summary>
/// The "time-to-live" or "TTL" that specifies the document's lifetime.
/// </summary>
TimeSpan Expiry { get; }
/// <summary>
/// A durability constraint ensuring that a document has been persisted to the n^th node.
/// </summary>
PersistTo PersistTo { get; }
/// <summary>
/// A durability constraint for ensuring that the document has been replicated to the n^th node.
/// </summary>
ReplicateTo ReplicateTo { get; }
/// <summary>
/// Inserts an element into a JSON document at a given path.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="value">An array value, dictionary entry, scalar or any other valid JSON item.</param>
/// <param name="createParents">If <s>true</s>, the parent will be added to the document. The default is true.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> Insert(string path, object value, bool createParents = true);
/// <summary>
/// Inserts an element into a JSON document at a given path.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="value">An array value, dictionary entry, scalar or any other valid JSON item.</param>
/// <param name="pathFlags">The lookup flags.</param>
/// <param name="docFlags">The document flags.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> Insert(string path, object value, SubdocPathFlags pathFlags, SubdocDocFlags docFlags = SubdocDocFlags.None);
/// <summary>
/// Inserts or updates an element within or into a JSON document at a given path.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="value">An array value, dictionary entry, scalar or any other valid JSON item.</param>
/// <param name="createParents">If <s>true</s>, the parent will be added to the document. The default is true.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> Upsert(string path, object value, bool createParents = true);
/// <summary>
/// Inserts or updates an element within or into a JSON document at a given path.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="value">An array value, dictionary entry, scalar or any other valid JSON item.</param>
/// <param name="pathFlags">The path flags.</param>
/// <param name="docFlags">The document flags.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> Upsert(string path, object value, SubdocPathFlags pathFlags, SubdocDocFlags docFlags = SubdocDocFlags.None);
/// <summary>
/// Replaces an element or value within a JSON document at a given path.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="value">An array value, dictionary entry, scalar or any other valid JSON item.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> Replace(string path, object value);
/// <summary>
/// Replaces an element or value within a JSON document at a given path.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="value">An array value, dictionary entry, scalar or any other valid JSON item.</param>
/// <param name="pathFlags">The path flags.</param>
/// <param name="docFlags">The document flags.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> Replace(string path, object value, SubdocPathFlags pathFlags, SubdocDocFlags docFlags = SubdocDocFlags.None);
/// <summary>
/// Removes an element or value from a JSON document at a given path.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> Remove(string path);
/// <summary>
/// Removes an element or value from a JSON document at a given path.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="pathFlags">The path flags.</param>
/// <param name="docFlags">The document flags.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> Remove(string path, SubdocPathFlags pathFlags, SubdocDocFlags docFlags = SubdocDocFlags.None);
/// <summary>
/// Inserts an array value at the end of an array that is the root of a JSON document.
/// </summary>
/// <param name="value">An array value.</param>
/// <param name="createParents">If <s>true</s>, the parent will be added to the document. The default is true.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> ArrayAppend(object value, bool createParents = true);
/// <summary>
/// Inserts one or more values at the end of an array that is the root of a JSON document.
/// </summary>
/// <param name="createParents">If <s>true</s>, the parent will be added to the document. The default is false.</param>
/// <param name="values">One or more values.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> ArrayAppend(bool createParents = false, params object[] values);
/// <summary>
/// Inserts a value to the end of an array in a JSON document at a given path.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="value">An aray value.</param>
/// <param name="createParents">If <s>true</s>, the parent will be added to the document. The default is true.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> ArrayAppend(string path, object value, bool createParents = true);
/// <summary>
/// Inserts a value to the end of an array in a JSON document at a given path.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="value">An aray value.</param>
/// <param name="pathFlags">The path flags.</param>
/// <param name="docFlags">The document flags.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> ArrayAppend(string path, object value, SubdocPathFlags pathFlags, SubdocDocFlags docFlags = SubdocDocFlags.None);
/// <summary>
/// Inserts one or more values to the end of an array in a JSON document at a given path.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="createParents">If <s>true</s>, the parent will be added to the document. The default is false.</param>
/// <param name="values">One or more values.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> ArrayAppend(string path, bool createParents = false, params object[] values);
/// <summary>
/// Inserts one or more values to the end of an array in a JSON document at a given path.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="pathFlags">The path flags.</param>
/// <param name="docFlags">The document flags.</param>
/// <param name="values">One or more values.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> ArrayAppend(string path, SubdocPathFlags pathFlags, SubdocDocFlags docFlags, params object[] values);
/// <summary>
/// Inserts a value to the beginning of an array that is the root of a JSON document.
/// </summary>
/// <param name="value">An array value, dictionary entry, scalar or any other valid JSON item.</param>
/// <param name="createParents">If <s>true</s>, the parent will be added to the document. The default is true.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> ArrayPrepend(object value, bool createParents = true);
/// <summary>
/// Inserts one or more values to the beginning of an array that is the root of a JSON document.
/// </summary>
/// <param name="createParents">If <s>true</s>, the parent will be added to the document. The default is false.</param>
/// <param name="values">One or more values.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> ArrayPrepend(bool createParents = false, params object[] values);
/// <summary>
/// Inserts a value to the beginning of an array in a JSON document at a given path.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="value">An array value.</param>
/// <param name="createParents">If <s>true</s>, the parent will be added to the document. The default is true.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> ArrayPrepend(string path, object value, bool createParents = true);
/// <summary>
/// Inserts a value to the beginning of an array in a JSON document at a given path.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="value">An array value.</param>
/// <param name="pathFlags">The path flags.</param>
/// <param name="docFlags">The document flags.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> ArrayPrepend(string path, object value, SubdocPathFlags pathFlags, SubdocDocFlags docFlags = SubdocDocFlags.None);
/// <summary>
/// Inserts one or more values to the beginning of an array in a JSON document at a given path.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="createParents">If <s>true</s>, the parent will be added to the document. The default is false.</param>
/// <param name="values">One or more values.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> ArrayPrepend(string path, bool createParents = false, params object[] values);
/// <summary>
/// Inserts one or more values to the beginning of an array in a JSON document at a given path.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="pathFlags">The path flags.</param>
/// <param name="docFlags">The document flags.</param>
/// <param name="values">One or more values.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> ArrayPrepend(string path, SubdocPathFlags pathFlags, SubdocDocFlags docFlags, params object[] values);
/// <summary>
/// Inserts a value at a given position within an array. The position is indicated as part of the path.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="value">A value.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> ArrayInsert(string path, object value);
/// <summary>
/// Inserts a value at a given position within an array. The position is indicated as part of the path.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="value">A value.</param>
/// <param name="pathFlags">The path flags.</param>
/// <param name="docFlags">The document flags.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> ArrayInsert(string path, object value, SubdocPathFlags pathFlags, SubdocDocFlags docFlags = SubdocDocFlags.None);
/// <summary>
/// Inserts one or more values at a given position within an array. The position is indicated as part of the path.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="values">One or more values.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> ArrayInsert(string path, params object[] values);
/// <summary>
/// Inserts one or more values at a given position within an array. The position is indicated as part of the path.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="pathFlags">The path flags.</param>
/// <param name="docFlags">The document flags.</param>
/// <param name="values">One or more values.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> ArrayInsert(string path, SubdocPathFlags pathFlags, SubdocDocFlags docFlags, params object[] values);
/// <summary>
/// Adds a value to an array if the value does not already exist in the array at the root of the JSON document.
/// </summary>
/// <param name="value">A unique value.</param>
/// <param name="createParents">If <s>true</s>, the parent will be added to the document. The default is true.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> ArrayAddUnique(object value, bool createParents = true);
/// <summary>
/// Adds a value to an array if the value does not already exist in the array.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="value">A unique value.</param>
/// <param name="createParents">If <s>true</s>, the parent will be added to the document. The default is true.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> ArrayAddUnique(string path, object value, bool createParents = true);
/// <summary>
/// Adds a value to an array if the value does not already exist in the array.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="value">A unique value.</param>
/// <param name="pathFlags">The path flags.</param>
/// <param name="docFlags">The document flags.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> ArrayAddUnique(string path, object value, SubdocPathFlags pathFlags, SubdocDocFlags docFlags = SubdocDocFlags.None);
/// <summary>
/// Performs an arithmetic increment or decrement operation on a numeric value in a document.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="delta">The value to increment or decrement the original value by.</param>
/// <param name="createParents">If <s>true</s>, the parent will be added to the document. The default is true.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> Counter(string path, long delta, bool createParents = true);
/// <summary>
/// Performs an arithmetic increment or decrement operation on a numeric value in a document.
/// </summary>
/// <param name="path">A string (N1QL syntax) used to specify a location within the document.</param>
/// <param name="delta">The value to increment or decrement the original value by.</param>
/// <param name="pathFlags">The path flags.</param>
/// <param name="docFlags">The document flags.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> Counter(string path, long delta, SubdocPathFlags pathFlags, SubdocDocFlags docFlags = SubdocDocFlags.None);
/// <summary>
/// Applies an expiration to a document.
/// </summary>
/// <param name="expiry">The "time-to-live" or TTL of the document.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> WithExpiry(TimeSpan expiry);
/// <summary>
/// A "check-and-set" value for ensuring that a document has not been modified by another thread.
/// </summary>
/// <param name="cas">The CAS value.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> WithCas(long cas);
/// <summary>
/// A "check-and-set" value for ensuring that a document has not been modified by another thread.
/// </summary>
/// <param name="cas">The CAS value.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> WithCas(ulong cas);
/// <summary>
/// A durability constraint ensuring that a document has been persisted to the n^th node.
/// </summary>
/// <param name="persistTo">The <see cref="PersistTo"/> value.</param>
/// <returns></returns>
IMutateInBuilder<TDocument> WithDurability(PersistTo persistTo);
/// <summary>
/// A durability constraint ensuring that a document has been persisted to the n^th node.
/// </summary>
/// <param name="replicateTo">The <see cref="ReplicateTo"/> value.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> WithDurability(ReplicateTo replicateTo);
/// <summary>
/// Sets the <see cref="ReplicateTo"/> and <see cref="PersistTo"/> values for a document.
/// </summary>
/// <param name="persistTo">The <see cref="PersistTo"/> value.</param>
/// <param name="replicateTo">The <see cref="ReplicateTo"/> value.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> WithDurability(PersistTo persistTo, ReplicateTo replicateTo);
/// <summary>
/// The maximum time allowed for an operation to live before timing out.
/// </summary>
/// <param name="timeout">The timeout.</param>
/// <returns>An <see cref="IMutateInBuilder{TDocument}"/> reference for chaining operations.</returns>
IMutateInBuilder<TDocument> WithTimeout(TimeSpan timeout);
}
}
#region [ License information ]
/* ************************************************************
*
* @author Couchbase <info@couchbase.com>
* @copyright 2017 Couchbase, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ************************************************************/
#endregion