@@ -6,7 +6,10 @@ import com.mongodb.client.model.DeleteOneModel
6
6
import com.mongodb.client.model.Filters
7
7
import com.mongodb.client.model.InsertOneModel
8
8
import com.mongodb.client.model.ReplaceOneModel
9
+ import com.mongodb.client.model.ReplaceOptions
10
+ import com.mongodb.client.model.Sorts
9
11
import com.mongodb.client.model.UpdateOneModel
12
+ import com.mongodb.client.model.UpdateOptions
10
13
import com.mongodb.client.model.Updates
11
14
import com.mongodb.kotlin.client.coroutine.MongoClient
12
15
import config.getConfig
@@ -95,6 +98,11 @@ internal class BulkTest {
95
98
val insert = Person (1 , " Celine Stork" , location = " San Diego, CA" )
96
99
val doc = ReplaceOneModel (filter, insert)
97
100
// :snippet-end:
101
+
102
+ // :snippet-start: replace-model-options
103
+ val opts = ReplaceOptions ().sort(Sorts .ascending(" _id" ))
104
+ // :snippet-end:
105
+
98
106
// Junit test for the above code
99
107
val insertTest = collection.bulkWrite(listOf (doc))
100
108
assertTrue(insertTest.wasAcknowledged())
@@ -107,6 +115,11 @@ internal class BulkTest {
107
115
val update = Updates .inc(Person ::age.name, 1 )
108
116
val doc = UpdateOneModel <Person >(filter, update)
109
117
// :snippet-end:
118
+
119
+ // :snippet-start: update-model-options
120
+ val opts = UpdateOptions ().sort(Sorts .ascending(" _id" ))
121
+ // :snippet-end:
122
+
110
123
// Junit test for the above code
111
124
val updateTest = collection.bulkWrite(listOf (doc))
112
125
assertTrue(updateTest.wasAcknowledged())
0 commit comments