...
1data:
2 - {_id: 1, x: 11}
3 - {_id: 2, x: 22}
4 - {_id: 3, x: 33}
5minServerVersion: '2.6'
6
7tests:
8 -
9 description: "UpdateOne when many documents match"
10 operation:
11 name: "updateOne"
12 arguments:
13 filter:
14 _id: {$gt: 1}
15 update:
16 $inc: {x: 1}
17
18 outcome:
19 result:
20 matchedCount: 1
21 modifiedCount: 1
22 upsertedCount: 0
23 # Can't verify collection data because we don't have a way of
24 # knowing which document gets updated.
25 -
26 description: "UpdateOne when one document matches"
27 operation:
28 name: "updateOne"
29 arguments:
30 filter: {_id: 1}
31 update:
32 $inc: {x: 1}
33
34 outcome:
35 result:
36 matchedCount: 1
37 modifiedCount: 1
38 upsertedCount: 0
39 collection:
40 data:
41 - {_id: 1, x: 12}
42 - {_id: 2, x: 22}
43 - {_id: 3, x: 33}
44 -
45 description: "UpdateOne when no documents match"
46 operation:
47 name: "updateOne"
48 arguments:
49 filter: {_id: 4}
50 update:
51 $inc: {x: 1}
52
53 outcome:
54 result:
55 matchedCount: 0
56 modifiedCount: 0
57 upsertedCount: 0
58 collection:
59 data:
60 - {_id: 1, x: 11}
61 - {_id: 2, x: 22}
62 - {_id: 3, x: 33}
63 -
64 description: "UpdateOne with upsert when no documents match"
65 operation:
66 name: "updateOne"
67 arguments:
68 filter: {_id: 4}
69 update:
70 $inc: {x: 1}
71 upsert: true
72
73 outcome:
74 result:
75 matchedCount: 0
76 modifiedCount: 0
77 upsertedCount: 1
78 upsertedId: 4
79 collection:
80 data:
81 - {_id: 1, x: 11}
82 - {_id: 2, x: 22}
83 - {_id: 3, x: 33}
84 - {_id: 4, x: 1}
View as plain text