Debian Codegraph @

testdata/crud/v1/write/updateOne-arrayFilters.json

raw
1 {
2 "data": [
3 {
4 "_id": 1,
5 "y": [
6 {
7 "b": 3
8 },
9 {
10 "b": 1
11 }
12 ]
13 },
14 {
15 "_id": 2,
16 "y": [
17 {
18 "b": 0
19 },
20 {
21 "b": 1
22 }
23 ]
24 },
25 {
26 "_id": 3,
27 "y": [
28 {
29 "b": 5,
30 "c": [
31 {
32 "d": 2
33 },
34 {
35 "d": 1
36 }
37 ]
38 }
39 ]
40 }
41 ],
42 "minServerVersion": "3.5.6",
43 "tests": [
44 {
45 "description": "UpdateOne when no document matches arrayFilters",
46 "operation": {
47 "name": "updateOne",
48 "arguments": {
49 "filter": {},
50 "update": {
51 "$set": {
52 "y.$[i].b": 2
53 }
54 },
55 "arrayFilters": [
56 {
57 "i.b": 4
58 }
59 ]
60 }
61 },
62 "outcome": {
63 "result": {
64 "matchedCount": 1,
65 "modifiedCount": 0,
66 "upsertedCount": 0
67 },
68 "collection": {
69 "data": [
70 {
71 "_id": 1,
72 "y": [
73 {
74 "b": 3
75 },
76 {
77 "b": 1
78 }
79 ]
80 },
81 {
82 "_id": 2,
83 "y": [
84 {
85 "b": 0
86 },
87 {
88 "b": 1
89 }
90 ]
91 },
92 {
93 "_id": 3,
94 "y": [
95 {
96 "b": 5,
97 "c": [
98 {
99 "d": 2
100 },
101 {
102 "d": 1
103 }
104 ]
105 }
106 ]
107 }
108 ]
109 }
110 }
111 },
112 {
113 "description": "UpdateOne when one document matches arrayFilters",
114 "operation": {
115 "name": "updateOne",
116 "arguments": {
117 "filter": {},
118 "update": {
119 "$set": {
120 "y.$[i].b": 2
121 }
122 },
123 "arrayFilters": [
124 {
125 "i.b": 3
126 }
127 ]
128 }
129 },
130 "outcome": {
131 "result": {
132 "matchedCount": 1,
133 "modifiedCount": 1,
134 "upsertedCount": 0
135 },
136 "collection": {
137 "data": [
138 {
139 "_id": 1,
140 "y": [
141 {
142 "b": 2
143 },
144 {
145 "b": 1
146 }
147 ]
148 },
149 {
150 "_id": 2,
151 "y": [
152 {
153 "b": 0
154 },
155 {
156 "b": 1
157 }
158 ]
159 },
160 {
161 "_id": 3,
162 "y": [
163 {
164 "b": 5,
165 "c": [
166 {
167 "d": 2
168 },
169 {
170 "d": 1
171 }
172 ]
173 }
174 ]
175 }
176 ]
177 }
178 }
179 },
180 {
181 "description": "UpdateOne when multiple documents match arrayFilters",
182 "operation": {
183 "name": "updateOne",
184 "arguments": {
185 "filter": {},
186 "update": {
187 "$set": {
188 "y.$[i].b": 2
189 }
190 },
191 "arrayFilters": [
192 {
193 "i.b": 1
194 }
195 ]
196 }
197 },
198 "outcome": {
199 "result": {
200 "matchedCount": 1,
201 "modifiedCount": 1,
202 "upsertedCount": 0
203 },
204 "collection": {
205 "data": [
206 {
207 "_id": 1,
208 "y": [
209 {
210 "b": 3
211 },
212 {
213 "b": 2
214 }
215 ]
216 },
217 {
218 "_id": 2,
219 "y": [
220 {
221 "b": 0
222 },
223 {
224 "b": 1
225 }
226 ]
227 },
228 {
229 "_id": 3,
230 "y": [
231 {
232 "b": 5,
233 "c": [
234 {
235 "d": 2
236 },
237 {
238 "d": 1
239 }
240 ]
241 }
242 ]
243 }
244 ]
245 }
246 }
247 },
248 {
249 "description": "UpdateOne when no documents match multiple arrayFilters",
250 "operation": {
251 "name": "updateOne",
252 "arguments": {
253 "filter": {
254 "_id": 3
255 },
256 "update": {
257 "$set": {
258 "y.$[i].c.$[j].d": 0
259 }
260 },
261 "arrayFilters": [
262 {
263 "i.b": 5
264 },
265 {
266 "j.d": 3
267 }
268 ]
269 }
270 },
271 "outcome": {
272 "result": {
273 "matchedCount": 1,
274 "modifiedCount": 0,
275 "upsertedCount": 0
276 },
277 "collection": {
278 "data": [
279 {
280 "_id": 1,
281 "y": [
282 {
283 "b": 3
284 },
285 {
286 "b": 1
287 }
288 ]
289 },
290 {
291 "_id": 2,
292 "y": [
293 {
294 "b": 0
295 },
296 {
297 "b": 1
298 }
299 ]
300 },
301 {
302 "_id": 3,
303 "y": [
304 {
305 "b": 5,
306 "c": [
307 {
308 "d": 2
309 },
310 {
311 "d": 1
312 }
313 ]
314 }
315 ]
316 }
317 ]
318 }
319 }
320 },
321 {
322 "description": "UpdateOne when one document matches multiple arrayFilters",
323 "operation": {
324 "name": "updateOne",
325 "arguments": {
326 "filter": {
327 "_id": 3
328 },
329 "update": {
330 "$set": {
331 "y.$[i].c.$[j].d": 0
332 }
333 },
334 "arrayFilters": [
335 {
336 "i.b": 5
337 },
338 {
339 "j.d": 1
340 }
341 ]
342 }
343 },
344 "outcome": {
345 "result": {
346 "matchedCount": 1,
347 "modifiedCount": 1,
348 "upsertedCount": 0
349 },
350 "collection": {
351 "data": [
352 {
353 "_id": 1,
354 "y": [
355 {
356 "b": 3
357 },
358 {
359 "b": 1
360 }
361 ]
362 },
363 {
364 "_id": 2,
365 "y": [
366 {
367 "b": 0
368 },
369 {
370 "b": 1
371 }
372 ]
373 },
374 {
375 "_id": 3,
376 "y": [
377 {
378 "b": 5,
379 "c": [
380 {
381 "d": 2
382 },
383 {
384 "d": 0
385 }
386 ]
387 }
388 ]
389 }
390 ]
391 }
392 }
393 }
394 ]
395 }