...
1data:
2 - {_id: 1, x: 11}
3 - {_id: 2, x: 22}
4 - {_id: 3, x: 33}
5
6tests:
7 -
8 description: "FindOneAndReplace when many documents match returning the document before modification"
9 operation:
10 name: findOneAndReplace
11 arguments:
12 filter:
13 _id: {$gt: 1}
14 replacement: {x: 32}
15 projection: {x: 1, _id: 0}
16 sort: {x: 1}
17
18 outcome:
19 result: {x: 22}
20 collection:
21 data:
22 - {_id: 1, x: 11}
23 - {_id: 2, x: 32}
24 - {_id: 3, x: 33}
25 -
26 description: "FindOneAndReplace when many documents match returning the document after modification"
27 operation:
28 name: findOneAndReplace
29 arguments:
30 filter:
31 _id: {$gt: 1}
32 replacement: {x: 32}
33 projection: {x: 1, _id: 0}
34 returnDocument: After
35 sort: {x: 1}
36
37 outcome:
38 result: {x: 32}
39 collection:
40 data:
41 - {_id: 1, x: 11}
42 - {_id: 2, x: 32}
43 - {_id: 3, x: 33}
44 -
45 description: "FindOneAndReplace when one document matches returning the document before modification"
46 operation:
47 name: findOneAndReplace
48 arguments:
49 filter: {_id: 2}
50 replacement: {x: 32}
51 projection: {x: 1, _id: 0}
52 sort: {x: 1}
53
54 outcome:
55 result: {x: 22}
56 collection:
57 data:
58 - {_id: 1, x: 11}
59 - {_id: 2, x: 32}
60 - {_id: 3, x: 33}
61 -
62 description: "FindOneAndReplace when one document matches returning the document after modification"
63 operation:
64 name: findOneAndReplace
65 arguments:
66 filter: {_id: 2}
67 replacement: {x: 32}
68 projection: {x: 1, _id: 0}
69 returnDocument: After
70 sort: {x: 1}
71
72 outcome:
73 result: {x: 32}
74 collection:
75 data:
76 - {_id: 1, x: 11}
77 - {_id: 2, x: 32}
78 - {_id: 3, x: 33}
79 -
80 description: "FindOneAndReplace when no documents match returning the document before modification"
81 operation:
82 name: findOneAndReplace
83 arguments:
84 filter: {_id: 4}
85 replacement: {x: 44}
86 projection: {x: 1, _id: 0}
87 sort: {x: 1}
88
89 outcome:
90 result: null
91 collection:
92 data:
93 - {_id: 1, x: 11}
94 - {_id: 2, x: 22}
95 - {_id: 3, x: 33}
96 -
97 description: "FindOneAndReplace when no documents match returning the document after modification"
98 operation:
99 name: findOneAndReplace
100 arguments:
101 filter: {_id: 4}
102 replacement: {x: 44}
103 projection: {x: 1, _id: 0}
104 returnDocument: After
105 sort: {x: 1}
106
107 outcome:
108 result: null
109 collection:
110 data:
111 - {_id: 1, x: 11}
112 - {_id: 2, x: 22}
113 - {_id: 3, x: 33}
View as plain text