@@ -47,12 +47,14 @@ internal class ClientBulkTest {
47
47
fun beforeAll () {
48
48
runBlocking {
49
49
personCollection.insertOne(Person (1 , " Sandy King" ))
50
- personCollection.insertOne(Person (1 ," Freya Polk" ,34 ))
51
- objectCollection.insertMany(listOf (
52
- Object (1 , " artist easel" ),
53
- Object (2 , " keyboard" , " electronic" ),
54
- Object (3 , " blender" ," electronic" ),
55
- ) )
50
+ personCollection.insertOne(Person (1 , " Freya Polk" , 34 ))
51
+ objectCollection.insertMany(
52
+ listOf (
53
+ Object (1 , " artist easel" ),
54
+ Object (2 , " keyboard" , " electronic" ),
55
+ Object (3 , " blender" , " electronic" ),
56
+ )
57
+ )
56
58
}
57
59
}
58
60
@@ -74,18 +76,20 @@ internal class ClientBulkTest {
74
76
// :snippet-start: insert-models
75
77
val docsToInsert = mutableListOf<ClientNamespacedWriteModel >()
76
78
77
- docsToInsert.add(ClientNamespacedWriteModel
78
- .insertOne(
79
- MongoNamespace (" sample_db" , " people" ),
80
- Person (2 , " Julia Smith" )
81
- )
79
+ docsToInsert.add(
80
+ ClientNamespacedWriteModel
81
+ .insertOne(
82
+ MongoNamespace (" sample_db" , " people" ),
83
+ Person (2 , " Julia Smith" )
84
+ )
82
85
)
83
86
84
- docsToInsert.add(ClientNamespacedWriteModel
85
- .insertOne(
86
- MongoNamespace (" sample_db" , " objects" ),
87
- Object (2 , " washing machine" )
88
- )
87
+ docsToInsert.add(
88
+ ClientNamespacedWriteModel
89
+ .insertOne(
90
+ MongoNamespace (" sample_db" , " objects" ),
91
+ Object (2 , " washing machine" )
92
+ )
89
93
)
90
94
91
95
val clientBulkResult = client.bulkWrite(docsToInsert)
@@ -104,20 +108,22 @@ internal class ClientBulkTest {
104
108
// :snippet-start: update-models
105
109
val docsToInsert = mutableListOf<ClientNamespacedWriteModel >()
106
110
107
- docsToInsert.add(ClientNamespacedWriteModel
108
- .updateOne(
109
- MongoNamespace (" sample_db" , " people" ),
110
- Filters .eq(Person ::name.name, " Freya Polk" ),
111
- Updates .inc(Person ::age.name, 1 )
112
- )
111
+ docsToInsert.add(
112
+ ClientNamespacedWriteModel
113
+ .updateOne(
114
+ MongoNamespace (" sample_db" , " people" ),
115
+ Filters .eq(Person ::name.name, " Freya Polk" ),
116
+ Updates .inc(Person ::age.name, 1 )
117
+ )
113
118
)
114
119
115
- docsToInsert.add(ClientNamespacedWriteModel
116
- .updateMany(
117
- MongoNamespace (" sample_db" , " objects" ),
118
- Filters .eq(Object ::category.name, " electronic" ),
119
- Updates .set(Object ::manufacturer.name, " Premium Technologies" )
120
- )
120
+ docsToInsert.add(
121
+ ClientNamespacedWriteModel
122
+ .updateMany(
123
+ MongoNamespace (" sample_db" , " objects" ),
124
+ Filters .eq(Object ::category.name, " electronic" ),
125
+ Updates .set(Object ::manufacturer.name, " Premium Technologies" )
126
+ )
121
127
)
122
128
123
129
val clientBulkResult = client.bulkWrite(docsToInsert)
@@ -132,20 +138,22 @@ internal class ClientBulkTest {
132
138
// :snippet-start: replace-models
133
139
val docsReplacements = mutableListOf<ClientNamespacedWriteModel >()
134
140
135
- docsReplacements.add(ClientNamespacedWriteModel
136
- .replaceOne(
137
- MongoNamespace (" sample_db" , " people" ),
138
- Filters .eq(Person ::id.name, 1 ),
139
- Person (1 , " Frederic Hilbert" )
140
- )
141
+ docsReplacements.add(
142
+ ClientNamespacedWriteModel
143
+ .replaceOne(
144
+ MongoNamespace (" sample_db" , " people" ),
145
+ Filters .eq(Person ::id.name, 1 ),
146
+ Person (1 , " Frederic Hilbert" )
147
+ )
141
148
)
142
149
143
- docsReplacements.add(ClientNamespacedWriteModel
144
- .replaceOne(
145
- MongoNamespace (" sample_db" , " objects" ),
146
- Filters .eq(Object ::id.name, 1 ),
147
- Object (1 , " ironing board" )
148
- )
150
+ docsReplacements.add(
151
+ ClientNamespacedWriteModel
152
+ .replaceOne(
153
+ MongoNamespace (" sample_db" , " objects" ),
154
+ Filters .eq(Object ::id.name, 1 ),
155
+ Object (1 , " ironing board" )
156
+ )
149
157
)
150
158
151
159
val clientBulkResult = client.bulkWrite(docsReplacements)
0 commit comments