@@ -16,7 +16,9 @@ With multi-region writes, when multiple clients write to the same item, conflict
16
16
17
17
These samples show how to set up a container with a last-writer-wins conflict resolution policy. The default path for last-writer-wins is the timestamp field or the ` _ts ` property. For SQL API, this may also be set to a user-defined path with a numeric type. In a conflict, the highest value wins. If the path isn't set or it's invalid, it defaults to ` _ts ` . Conflicts resolved with this policy do not show up in the conflict feed. This policy can be used by all APIs.
18
18
19
- ### <a id =" create-custom-conflict-resolution-policy-lww-dotnet " ></a >.NET SDK V2
19
+ ### <a id =" create-custom-conflict-resolution-policy-lww-dotnet " ></a >.NET SDK
20
+
21
+ # [ .NET SDK V2] ( #tab/dotnetv2 )
20
22
21
23
``` csharp
22
24
DocumentCollection lwwCollection = await createClient .CreateDocumentCollectionIfNotExistsAsync (
@@ -31,7 +33,7 @@ DocumentCollection lwwCollection = await createClient.CreateDocumentCollectionIf
31
33
});
32
34
```
33
35
34
- ### < a id = " create-custom-conflict-resolution-policy-lww-dotnet-v3 " ></ a > .NET SDK V3
36
+ # [ .NET SDK V3] ( #tab/dotnetv3 )
35
37
36
38
``` csharp
37
39
Container container = await createClient .GetDatabase (this .databaseName )
@@ -44,8 +46,11 @@ Container container = await createClient.GetDatabase(this.databaseName)
44
46
}
45
47
});
46
48
```
49
+ ---
50
+
51
+ ### <a id =" create-custom-conflict-resolution-policy-lww-java " ></a >Java SDK
47
52
48
- ### < a id = " create-custom-conflict-resolution-policy-lww-java-async " ></ a > Java Async SDK
53
+ # [ Java Async SDK] ( #tab/javaasync )
49
54
50
55
``` java
51
56
DocumentCollection collection = new DocumentCollection ();
@@ -55,7 +60,7 @@ collection.setConflictResolutionPolicy(policy);
55
60
DocumentCollection createdCollection = client. createCollection(databaseUri, collection, null ). toBlocking(). value();
56
61
```
57
62
58
- ### < a id = " create-custom-conflict-resolution-policy-lww-java- sync" ></ a >Java Sync SDK
63
+ # [ Java sync SDK] ( #tab/javasync )
59
64
60
65
``` java
61
66
DocumentCollection lwwCollection = new DocumentCollection ();
@@ -64,6 +69,7 @@ ConflictResolutionPolicy lwwPolicy = ConflictResolutionPolicy.createLastWriterWi
64
69
lwwCollection. setConflictResolutionPolicy(lwwPolicy);
65
70
DocumentCollection createdCollection = this . tryCreateDocumentCollection(createClient, database, lwwCollection);
66
71
```
72
+ ---
67
73
68
74
### <a id =" create-custom-conflict-resolution-policy-lww-javascript " ></a >Node.js/JavaScript/TypeScript SDK
69
75
@@ -166,7 +172,9 @@ function resolver(incomingItem, existingItem, isTombstone, conflictingItems) {
166
172
}
167
173
```
168
174
169
- ### <a id =" create-custom-conflict-resolution-policy-stored-proc-dotnet " ></a >.NET SDK V2
175
+ ### <a id =" create-custom-conflict-resolution-policy-stored-proc-dotnet " ></a >.NET SDK
176
+
177
+ # [ .NET SDK V2] ( #tab/dotnetv2 )
170
178
171
179
``` csharp
172
180
DocumentCollection udpCollection = await createClient .CreateDocumentCollectionIfNotExistsAsync (
@@ -189,7 +197,7 @@ UriFactory.CreateStoredProcedureUri(this.databaseName, this.udpCollectionName, "
189
197
});
190
198
```
191
199
192
- ### < a id = " create-custom-conflict-resolution-policy-stored-proc-dotnet-v3 " ></ a > .NET SDK V3
200
+ # [ .NET SDK V3] ( #tab/dotnetv3 )
193
201
194
202
``` csharp
195
203
Container container = await createClient .GetDatabase (this .databaseName )
@@ -206,8 +214,11 @@ await container.Scripts.CreateStoredProcedureAsync(
206
214
new StoredProcedureProperties (" resolver" , File .ReadAllText (@" resolver.js" ))
207
215
);
208
216
```
217
+ ---
218
+
219
+ ### <a id =" create-custom-conflict-resolution-policy-stored-proc-java " ></a >Java SDK
209
220
210
- ### < a id = " create-custom-conflict-resolution-policy-stored-proc-java-async " ></ a > Java Async SDK
221
+ # [ Java Async SDK] ( #tab/javaasync )
211
222
212
223
``` java
213
224
DocumentCollection collection = new DocumentCollection ();
@@ -219,7 +230,7 @@ DocumentCollection createdCollection = client.createCollection(databaseUri, coll
219
230
220
231
After your container is created, you must create the ` resolver ` stored procedure.
221
232
222
- ### < a id = " create-custom-conflict-resolution-policy-stored-proc-java- sync" ></ a >Java Sync SDK
233
+ # [ Java sync SDK] ( #tab/javasync )
223
234
224
235
``` java
225
236
DocumentCollection udpCollection = new DocumentCollection ();
@@ -229,6 +240,7 @@ ConflictResolutionPolicy udpPolicy = ConflictResolutionPolicy.createCustomPolicy
229
240
udpCollection. setConflictResolutionPolicy(udpPolicy);
230
241
DocumentCollection createdCollection = this . tryCreateDocumentCollection(createClient, database, udpCollection);
231
242
```
243
+ ---
232
244
233
245
After your container is created, you must create the ` resolver ` stored procedure.
234
246
@@ -271,7 +283,9 @@ After your container is created, you must create the `resolver` stored procedure
271
283
272
284
These samples show how to set up a container with a custom conflict resolution policy. These conflicts show up in the conflict feed.
273
285
274
- ### <a id =" create-custom-conflict-resolution-policy-dotnet " ></a >.NET SDK V2
286
+ ### <a id =" create-custom-conflict-resolution-policy-dotnet " ></a >.NET SDK
287
+
288
+ # [ .NET SDK V2] ( #tab/dotnetv2 )
275
289
276
290
``` csharp
277
291
DocumentCollection manualCollection = await createClient .CreateDocumentCollectionIfNotExistsAsync (
@@ -284,8 +298,7 @@ DocumentCollection manualCollection = await createClient.CreateDocumentCollectio
284
298
},
285
299
});
286
300
```
287
-
288
- ### <a id =" create-custom-conflict-resolution-policy-dotnet-v3 " ></a >.NET SDK V3
301
+ # [ .NET SDK V3] ( #tab/dotnetv3 )
289
302
290
303
``` csharp
291
304
Container container = await createClient .GetDatabase (this .databaseName )
@@ -297,8 +310,11 @@ Container container = await createClient.GetDatabase(this.databaseName)
297
310
}
298
311
});
299
312
```
313
+ ---
300
314
301
- ### <a id =" create-custom-conflict-resolution-policy-java-async " ></a >Java Async SDK
315
+ ### <a id =" create-custom-conflict-resolution-policy-java " ></a >Java SDK
316
+
317
+ # [ Java Async SDK] ( #tab/javaasync )
302
318
303
319
``` java
304
320
DocumentCollection collection = new DocumentCollection ();
@@ -308,7 +324,7 @@ collection.setConflictResolutionPolicy(policy);
308
324
DocumentCollection createdCollection = client. createCollection(databaseUri, collection, null ). toBlocking(). value();
309
325
```
310
326
311
- ### < a id = " create-custom-conflict-resolution-policy-java- sync" ></ a >Java Sync SDK
327
+ # [ Java sync SDK] ( #tab/javasync )
312
328
313
329
``` java
314
330
DocumentCollection manualCollection = new DocumentCollection ();
@@ -317,6 +333,7 @@ ConflictResolutionPolicy customPolicy = ConflictResolutionPolicy.createCustomPol
317
333
manualCollection. setConflictResolutionPolicy(customPolicy);
318
334
DocumentCollection createdCollection = client. createCollection(database. getSelfLink(), collection, null ). getResource();
319
335
```
336
+ ---
320
337
321
338
### <a id =" create-custom-conflict-resolution-policy-javascript " ></a >Node.js/JavaScript/TypeScript SDK
322
339
@@ -349,13 +366,15 @@ manual_collection = client.CreateContainer(database['_self'], collection)
349
366
350
367
These samples show how to read from a container's conflict feed. Conflicts show up in the conflict feed only if they weren't resolved automatically or if using a custom conflict policy.
351
368
352
- ### <a id =" read-from-conflict-feed-dotnet " ></a >.NET SDK V2
369
+ ### <a id =" read-from-conflict-feed-dotnet " ></a >.NET SDK
370
+
371
+ # [ .NET SDK V2] ( #tab/dotnetv2 )
353
372
354
373
``` csharp
355
374
FeedResponse < Conflict > conflicts = await delClient .ReadConflictFeedAsync (this .collectionUri );
356
375
```
357
376
358
- ### < a id = " read-from-conflict-feed-dotnet-v3 " ></ a > .NET SDK V3
377
+ # [ .NET SDK V3] ( #tab/dotnetv3 )
359
378
360
379
``` csharp
361
380
FeedIterator < ConflictProperties > conflictFeed = container .Conflicts .GetConflictQueryIterator ();
@@ -377,7 +396,9 @@ while (conflictFeed.HasMoreResults)
377
396
}
378
397
```
379
398
380
- ### <a id =" read-from-conflict-feed-java-async " ></a >Java Async SDK
399
+ ### <a id =" read-from-conflict-feed-java " ></a >Java SDK
400
+
401
+ # [ Java Async SDK] ( #tab/javaasync )
381
402
382
403
``` java
383
404
FeedResponse<Conflict > response = client. readConflicts(this . manualCollectionUri, null )
@@ -386,8 +407,7 @@ for (Conflict conflict : response.getResults()) {
386
407
/* Do something with conflict */
387
408
}
388
409
```
389
-
390
- ### <a id =" read-from-conflict-feed-java-sync " ></a >Java Sync SDK
410
+ # [ Java Async SDK] ( #tab/javaasync )
391
411
392
412
``` java
393
413
Iterator<Conflict > conflictsIterator = client. readConflicts(this . collectionLink, null ). getQueryIterator();
@@ -396,6 +416,7 @@ while (conflictsIterator.hasNext()) {
396
416
/* Do something with conflict */
397
417
}
398
418
```
419
+ ---
399
420
400
421
### <a id =" read-from-conflict-feed-javascript " ></a >Node.js/JavaScript/TypeScript SDK
401
422
0 commit comments