@@ -117,15 +117,10 @@ const { container: lwwContainer } = await database.containers.createIfNotExists(
117
117
### <a id =" create-custom-conflict-resolution-policy-lww-python " ></a >Python SDK
118
118
119
119
``` python
120
- udp_collection = {
121
- ' id' : self .udp_collection_name,
122
- ' conflictResolutionPolicy' : {
123
- ' mode' : ' LastWriterWins' ,
124
- ' conflictResolutionPath' : ' /myCustomId'
125
- }
126
- }
127
- udp_collection = self .try_create_document_collection(
128
- create_client, database, udp_collection)
120
+ database = client.get_database_client(database = database_id)
121
+ lww_conflict_resolution_policy = {' mode' : ' LastWriterWins' , ' conflictResolutionPath' : ' /regionId' }
122
+ lww_container = database.create_container(id = lww_container_id, partition_key = PartitionKey(path = " /id" ),
123
+ conflict_resolution_policy = lww_conflict_resolution_policy)
129
124
```
130
125
131
126
## Create a custom conflict resolution policy using a stored procedure
@@ -314,15 +309,10 @@ After your container is created, you must create the `resolver` stored procedure
314
309
### <a id =" create-custom-conflict-resolution-policy-stored-proc-python " ></a >Python SDK
315
310
316
311
``` python
317
- udp_collection = {
318
- ' id' : self .udp_collection_name,
319
- ' conflictResolutionPolicy' : {
320
- ' mode' : ' Custom' ,
321
- ' conflictResolutionProcedure' : ' dbs/' + self .database_name + " /colls/" + self .udp_collection_name + ' /sprocs/resolver'
322
- }
323
- }
324
- udp_collection = self .try_create_document_collection(
325
- create_client, database, udp_collection)
312
+ database = client.get_database_client(database = database_id)
313
+ udp_custom_resolution_policy = {' mode' : ' Custom' }
314
+ udp_container = database.create_container(id = udp_container_id, partition_key = PartitionKey(path = " /id" ),
315
+ conflict_resolution_policy = udp_custom_resolution_policy)
326
316
```
327
317
328
318
After your container is created, you must create the ` resolver ` stored procedure.
@@ -421,14 +411,10 @@ const {
421
411
### <a id =" create-custom-conflict-resolution-policy-python " ></a >Python SDK
422
412
423
413
``` python
424
- database = client.ReadDatabase(" dbs/" + self .database_name)
425
- manual_collection = {
426
- ' id' : self .manual_collection_name,
427
- ' conflictResolutionPolicy' : {
428
- ' mode' : ' Custom'
429
- }
430
- }
431
- manual_collection = client.CreateContainer(database[' _self' ], collection)
414
+ database = client.get_database_client(database = database_id)
415
+ manual_resolution_policy = {' mode' : ' Custom' }
416
+ manual_container = database.create_container(id = manual_container_id, partition_key = PartitionKey(path = " /id" ),
417
+ conflict_resolution_policy = manual_resolution_policy)
432
418
```
433
419
434
420
## Read from conflict feed
@@ -509,7 +495,7 @@ const { result: conflicts } = await container.conflicts.readAll().toArray();
509
495
### <a id =" read-from-conflict-feed-python " ></a >Python
510
496
511
497
``` python
512
- conflicts_iterator = iter (client.ReadConflicts( self .manual_collection_link ))
498
+ conflicts_iterator = iter (container.list_conflicts( ))
513
499
conflict = next (conflicts_iterator, None )
514
500
while conflict:
515
501
# Do something with conflict
0 commit comments