@@ -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/async )
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/sync )
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/async )
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/sync )
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 (
@@ -285,7 +299,7 @@ DocumentCollection manualCollection = await createClient.CreateDocumentCollectio
285
299
});
286
300
```
287
301
288
- ### < a id = " create-custom-conflict-resolution-policy-dotnet-v3 " ></ a > .NET SDK V3
302
+ # [ .NET SDK V3] ( #tab/dotnetv3 )
289
303
290
304
``` csharp
291
305
Container container = await createClient .GetDatabase (this .databaseName )
@@ -297,8 +311,11 @@ Container container = await createClient.GetDatabase(this.databaseName)
297
311
}
298
312
});
299
313
```
314
+ ---
315
+
316
+ ### <a id =" create-custom-conflict-resolution-policy-java " ></a >Java SDK
300
317
301
- ### < a id = " create-custom-conflict-resolution-policy-java-async " ></ a > Java Async SDK
318
+ # [ Java Async SDK] ( #tab/async )
302
319
303
320
``` java
304
321
DocumentCollection collection = new DocumentCollection ();
@@ -308,7 +325,7 @@ collection.setConflictResolutionPolicy(policy);
308
325
DocumentCollection createdCollection = client. createCollection(databaseUri, collection, null ). toBlocking(). value();
309
326
```
310
327
311
- ### < a id = " create-custom-conflict-resolution-policy-java- sync" ></ a >Java Sync SDK
328
+ # [ Java sync SDK] ( #tab/sync )
312
329
313
330
``` java
314
331
DocumentCollection manualCollection = new DocumentCollection ();
@@ -317,6 +334,7 @@ ConflictResolutionPolicy customPolicy = ConflictResolutionPolicy.createCustomPol
317
334
manualCollection. setConflictResolutionPolicy(customPolicy);
318
335
DocumentCollection createdCollection = client. createCollection(database. getSelfLink(), collection, null ). getResource();
319
336
```
337
+ ---
320
338
321
339
### <a id =" create-custom-conflict-resolution-policy-javascript " ></a >Node.js/JavaScript/TypeScript SDK
322
340
@@ -349,13 +367,15 @@ manual_collection = client.CreateContainer(database['_self'], collection)
349
367
350
368
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
369
352
- ### <a id =" read-from-conflict-feed-dotnet " ></a >.NET SDK V2
370
+ ### <a id =" read-from-conflict-feed-dotnet " ></a >.NET SDK
371
+
372
+ # [ .NET SDK V2] ( #tab/dotnetv2 )
353
373
354
374
``` csharp
355
375
FeedResponse < Conflict > conflicts = await delClient .ReadConflictFeedAsync (this .collectionUri );
356
376
```
357
377
358
- ### < a id = " read-from-conflict-feed-dotnet-v3 " ></ a > .NET SDK V3
378
+ # [ .NET SDK V3] ( #tab/dotnetv3 )
359
379
360
380
``` csharp
361
381
FeedIterator < ConflictProperties > conflictFeed = container .Conflicts .GetConflictQueryIterator ();
@@ -376,8 +396,11 @@ while (conflictFeed.HasMoreResults)
376
396
}
377
397
}
378
398
```
399
+ ---
400
+
401
+ ### <a id =" read-from-conflict-feed-java " ></a >Java SDK
379
402
380
- ### < a id = " read-from-conflict-feed-java-async " ></ a > Java Async SDK
403
+ # [ Java Async SDK] ( #tab/async )
381
404
382
405
``` java
383
406
FeedResponse<Conflict > response = client. readConflicts(this . manualCollectionUri, null )
@@ -386,8 +409,7 @@ for (Conflict conflict : response.getResults()) {
386
409
/* Do something with conflict */
387
410
}
388
411
```
389
-
390
- ### <a id =" read-from-conflict-feed-java-sync " ></a >Java Sync SDK
412
+ # [ Java Async SDK] ( #tab/sync )
391
413
392
414
``` java
393
415
Iterator<Conflict > conflictsIterator = client. readConflicts(this . collectionLink, null ). getQueryIterator();
@@ -396,6 +418,7 @@ while (conflictsIterator.hasNext()) {
396
418
/* Do something with conflict */
397
419
}
398
420
```
421
+ ---
399
422
400
423
### <a id =" read-from-conflict-feed-javascript " ></a >Node.js/JavaScript/TypeScript SDK
401
424
0 commit comments