...
1# This file was created automatically using mongodb-spec-converter.
2# Please review the generated file, then remove this notice.
3
4description: updateWithPipelines
5schemaVersion: '1.0'
6runOnRequirements:
7 -
8 minServerVersion: 4.1.11
9createEntities:
10 -
11 client:
12 id: &client0 client0
13 observeEvents:
14 - commandStartedEvent
15 -
16 database:
17 id: &database0 database0
18 client: client0
19 databaseName: &database_name crud-tests
20 -
21 collection:
22 id: &collection0 collection0
23 database: database0
24 collectionName: &collection_name test
25initialData:
26 -
27 collectionName: *collection_name
28 databaseName: *database_name
29 documents:
30 -
31 _id: 1
32 x: 1
33 'y': 1
34 t:
35 u:
36 v: 1
37 -
38 _id: 2
39 x: 2
40 'y': 1
41tests:
42 -
43 description: 'UpdateOne using pipelines'
44 operations:
45 -
46 object: *collection0
47 name: updateOne
48 arguments:
49 filter:
50 _id: 1
51 update:
52 -
53 $replaceRoot:
54 newRoot: $t
55 -
56 $addFields:
57 foo: 1
58 expectResult:
59 matchedCount: 1
60 modifiedCount: 1
61 upsertedCount: 0
62 expectEvents:
63 -
64 client: *client0
65 events:
66 -
67 commandStartedEvent:
68 command:
69 update: *collection_name
70 updates:
71 -
72 q:
73 _id: 1
74 u:
75 - { $replaceRoot: { newRoot: $t } }
76 - { $addFields: { foo: 1 } }
77 multi: { $$unsetOrMatches: false }
78 upsert: { $$unsetOrMatches: false }
79 commandName: update
80 databaseName: *database_name
81 outcome:
82 -
83 collectionName: *collection_name
84 databaseName: *database_name
85 documents:
86 -
87 _id: 1
88 u:
89 v: 1
90 foo: 1
91 -
92 _id: 2
93 x: 2
94 'y': 1
95 -
96 description: 'UpdateMany using pipelines'
97 operations:
98 -
99 object: *collection0
100 name: updateMany
101 arguments:
102 filter: { }
103 update:
104 -
105 $project:
106 x: 1
107 -
108 $addFields:
109 foo: 1
110 expectResult:
111 matchedCount: 2
112 modifiedCount: 2
113 upsertedCount: 0
114 expectEvents:
115 -
116 client: *client0
117 events:
118 -
119 commandStartedEvent:
120 command:
121 update: *collection_name
122 updates:
123 -
124 q: { }
125 u:
126 - { $project: { x: 1 } }
127 - { $addFields: { foo: 1 } }
128 multi: true
129 upsert: { $$unsetOrMatches: false }
130 commandName: update
131 databaseName: *database_name
132 outcome:
133 -
134 collectionName: *collection_name
135 databaseName: *database_name
136 documents:
137 -
138 _id: 1
139 x: 1
140 foo: 1
141 -
142 _id: 2
143 x: 2
144 foo: 1
145 -
146 description: 'FindOneAndUpdate using pipelines'
147 operations:
148 -
149 object: *collection0
150 name: findOneAndUpdate
151 arguments:
152 filter:
153 _id: 1
154 update:
155 -
156 $project:
157 x: 1
158 -
159 $addFields:
160 foo: 1
161 expectEvents:
162 -
163 client: *client0
164 events:
165 -
166 commandStartedEvent:
167 command:
168 findAndModify: *collection_name
169 update:
170 -
171 $project:
172 x: 1
173 -
174 $addFields:
175 foo: 1
176 commandName: findAndModify
177 databaseName: *database_name
178 outcome:
179 -
180 collectionName: *collection_name
181 databaseName: *database_name
182 documents:
183 -
184 _id: 1
185 x: 1
186 foo: 1
187 -
188 _id: 2
189 x: 2
190 'y': 1
191 -
192 description: 'UpdateOne in bulk write using pipelines'
193 operations:
194 -
195 object: *collection0
196 name: bulkWrite
197 arguments:
198 requests:
199 -
200 updateOne:
201 filter:
202 _id: 1
203 update:
204 -
205 $replaceRoot:
206 newRoot: $t
207 -
208 $addFields:
209 foo: 1
210 expectResult:
211 matchedCount: 1
212 modifiedCount: 1
213 upsertedCount: 0
214 expectEvents:
215 -
216 client: *client0
217 events:
218 -
219 commandStartedEvent:
220 command:
221 update: *collection_name
222 updates:
223 -
224 q:
225 _id: 1
226 u:
227 - { $replaceRoot: { newRoot: $t } }
228 - { $addFields: { foo: 1 } }
229 multi: { $$unsetOrMatches: false }
230 upsert: { $$unsetOrMatches: false }
231 commandName: update
232 databaseName: *database_name
233 outcome:
234 -
235 collectionName: *collection_name
236 databaseName: *database_name
237 documents:
238 -
239 _id: 1
240 u:
241 v: 1
242 foo: 1
243 -
244 _id: 2
245 x: 2
246 'y': 1
247 -
248 description: 'UpdateMany in bulk write using pipelines'
249 operations:
250 -
251 object: *collection0
252 name: bulkWrite
253 arguments:
254 requests:
255 -
256 updateMany:
257 filter: { }
258 update:
259 -
260 $project:
261 x: 1
262 -
263 $addFields:
264 foo: 1
265 expectResult:
266 matchedCount: 2
267 modifiedCount: 2
268 upsertedCount: 0
269 expectEvents:
270 -
271 client: *client0
272 events:
273 -
274 commandStartedEvent:
275 command:
276 update: *collection_name
277 updates:
278 -
279 q: { }
280 u:
281 - { $project: { x: 1 } }
282 - { $addFields: { foo: 1 } }
283 multi: true
284 upsert: { $$unsetOrMatches: false }
285 commandName: update
286 databaseName: *database_name
287 outcome:
288 -
289 collectionName: *collection_name
290 databaseName: *database_name
291 documents:
292 -
293 _id: 1
294 x: 1
295 foo: 1
296 -
297 _id: 2
298 x: 2
299 foo: 1
View as plain text