...
1data:
2 - {_id: 1, x: 11}
3 - {_id: 2, x: 22}
4 - {_id: 3, x: 33}
5minServerVersion: '2.6'
6
7tests:
8 -
9 description: "FindOneAndReplace when no documents match without id specified with upsert returning the document before modification"
10 operation:
11 name: findOneAndReplace
12 arguments:
13 filter: {_id: 4}
14 replacement: {x: 44}
15 projection: {x: 1, _id: 0}
16 # Omit the sort option as it has no effect when no documents
17 # match and would only cause an inconsistent return value on
18 # pre-3.0 servers when combined with returnDocument "before"
19 # (see: SERVER-17650).
20 upsert: true
21
22 outcome:
23 result: null
24 collection:
25 data:
26 - {_id: 1, x: 11}
27 - {_id: 2, x: 22}
28 - {_id: 3, x: 33}
29 - {_id: 4, x: 44}
30 -
31 description: "FindOneAndReplace when no documents match without id specified with upsert returning the document after modification"
32 operation:
33 name: findOneAndReplace
34 arguments:
35 filter: {_id: 4}
36 replacement: {x: 44}
37 projection: {x: 1, _id: 0}
38 returnDocument: After
39 sort: {x: 1}
40 upsert: true
41
42 outcome:
43 result: {x: 44}
44 collection:
45 data:
46 - {_id: 1, x: 11}
47 - {_id: 2, x: 22}
48 - {_id: 3, x: 33}
49 - {_id: 4, x: 44}
50 -
51 description: "FindOneAndReplace when no documents match with id specified with upsert returning the document before modification"
52 operation:
53 name: findOneAndReplace
54 arguments:
55 filter: {_id: 4}
56 replacement: {_id: 4, x: 44}
57 projection: {x: 1, _id: 0}
58 # Omit the sort option as it has no effect when no documents
59 # match and would only cause an inconsistent return value on
60 # pre-3.0 servers when combined with returnDocument "before"
61 # (see: SERVER-17650).
62 upsert: true
63
64 outcome:
65 result: null
66 collection:
67 data:
68 - {_id: 1, x: 11}
69 - {_id: 2, x: 22}
70 - {_id: 3, x: 33}
71 - {_id: 4, x: 44}
72 -
73 description: "FindOneAndReplace when no documents match with id specified with upsert returning the document after modification"
74 operation:
75 name: findOneAndReplace
76 arguments:
77 filter: {_id: 4}
78 replacement: {_id: 4, x: 44}
79 projection: {x: 1, _id: 0}
80 returnDocument: After
81 sort: {x: 1}
82 upsert: true
83
84 outcome:
85 result: {x: 44}
86 collection:
87 data:
88 - {_id: 1, x: 11}
89 - {_id: 2, x: 22}
90 - {_id: 3, x: 33}
91 - {_id: 4, x: 44}
View as plain text