Debian Codegraph @

testdata/crud/v1/write/updateMany-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 "minServerVersion": "3.5.6",
27 "tests": [
28 {
29 "description": "UpdateMany when no documents match arrayFilters",
30 "operation": {
31 "name": "updateMany",
32 "arguments": {
33 "filter": {},
34 "update": {
35 "$set": {
36 "y.$[i].b": 2
37 }
38 },
39 "arrayFilters": [
40 {
41 "i.b": 4
42 }
43 ]
44 }
45 },
46 "outcome": {
47 "result": {
48 "matchedCount": 2,
49 "modifiedCount": 0,
50 "upsertedCount": 0
51 },
52 "collection": {
53 "data": [
54 {
55 "_id": 1,
56 "y": [
57 {
58 "b": 3
59 },
60 {
61 "b": 1
62 }
63 ]
64 },
65 {
66 "_id": 2,
67 "y": [
68 {
69 "b": 0
70 },
71 {
72 "b": 1
73 }
74 ]
75 }
76 ]
77 }
78 }
79 },
80 {
81 "description": "UpdateMany when one document matches arrayFilters",
82 "operation": {
83 "name": "updateMany",
84 "arguments": {
85 "filter": {},
86 "update": {
87 "$set": {
88 "y.$[i].b": 2
89 }
90 },
91 "arrayFilters": [
92 {
93 "i.b": 3
94 }
95 ]
96 }
97 },
98 "outcome": {
99 "result": {
100 "matchedCount": 2,
101 "modifiedCount": 1,
102 "upsertedCount": 0
103 },
104 "collection": {
105 "data": [
106 {
107 "_id": 1,
108 "y": [
109 {
110 "b": 2
111 },
112 {
113 "b": 1
114 }
115 ]
116 },
117 {
118 "_id": 2,
119 "y": [
120 {
121 "b": 0
122 },
123 {
124 "b": 1
125 }
126 ]
127 }
128 ]
129 }
130 }
131 },
132 {
133 "description": "UpdateMany when multiple documents match arrayFilters",
134 "operation": {
135 "name": "updateMany",
136 "arguments": {
137 "filter": {},
138 "update": {
139 "$set": {
140 "y.$[i].b": 2
141 }
142 },
143 "arrayFilters": [
144 {
145 "i.b": 1
146 }
147 ]
148 }
149 },
150 "outcome": {
151 "result": {
152 "matchedCount": 2,
153 "modifiedCount": 2,
154 "upsertedCount": 0
155 },
156 "collection": {
157 "data": [
158 {
159 "_id": 1,
160 "y": [
161 {
162 "b": 3
163 },
164 {
165 "b": 2
166 }
167 ]
168 },
169 {
170 "_id": 2,
171 "y": [
172 {
173 "b": 0
174 },
175 {
176 "b": 2
177 }
178 ]
179 }
180 ]
181 }
182 }
183 }
184 ]
185 }