| 1 |
{ |
| 2 |
"data": [ |
| 3 |
{ |
| 4 |
"_id": 1, |
| 5 |
"x": 11 |
| 6 |
}, |
| 7 |
{ |
| 8 |
"_id": 2, |
| 9 |
"x": 22 |
| 10 |
}, |
| 11 |
{ |
| 12 |
"_id": 3, |
| 13 |
"x": 33 |
| 14 |
} |
| 15 |
], |
| 16 |
"minServerVersion": "2.6", |
| 17 |
"tests": [ |
| 18 |
{ |
| 19 |
"description": "ReplaceOne when many documents match", |
| 20 |
"operation": { |
| 21 |
"name": "replaceOne", |
| 22 |
"arguments": { |
| 23 |
"filter": { |
| 24 |
"_id": { |
| 25 |
"$gt": 1 |
| 26 |
} |
| 27 |
}, |
| 28 |
"replacement": { |
| 29 |
"x": 111 |
| 30 |
} |
| 31 |
} |
| 32 |
}, |
| 33 |
"outcome": { |
| 34 |
"result": { |
| 35 |
"matchedCount": 1, |
| 36 |
"modifiedCount": 1, |
| 37 |
"upsertedCount": 0 |
| 38 |
} |
| 39 |
} |
| 40 |
}, |
| 41 |
{ |
| 42 |
"description": "ReplaceOne when one document matches", |
| 43 |
"operation": { |
| 44 |
"name": "replaceOne", |
| 45 |
"arguments": { |
| 46 |
"filter": { |
| 47 |
"_id": 1 |
| 48 |
}, |
| 49 |
"replacement": { |
| 50 |
"_id": 1, |
| 51 |
"x": 111 |
| 52 |
} |
| 53 |
} |
| 54 |
}, |
| 55 |
"outcome": { |
| 56 |
"result": { |
| 57 |
"matchedCount": 1, |
| 58 |
"modifiedCount": 1, |
| 59 |
"upsertedCount": 0 |
| 60 |
}, |
| 61 |
"collection": { |
| 62 |
"data": [ |
| 63 |
{ |
| 64 |
"_id": 1, |
| 65 |
"x": 111 |
| 66 |
}, |
| 67 |
{ |
| 68 |
"_id": 2, |
| 69 |
"x": 22 |
| 70 |
}, |
| 71 |
{ |
| 72 |
"_id": 3, |
| 73 |
"x": 33 |
| 74 |
} |
| 75 |
] |
| 76 |
} |
| 77 |
} |
| 78 |
}, |
| 79 |
{ |
| 80 |
"description": "ReplaceOne when no documents match", |
| 81 |
"operation": { |
| 82 |
"name": "replaceOne", |
| 83 |
"arguments": { |
| 84 |
"filter": { |
| 85 |
"_id": 4 |
| 86 |
}, |
| 87 |
"replacement": { |
| 88 |
"_id": 4, |
| 89 |
"x": 1 |
| 90 |
} |
| 91 |
} |
| 92 |
}, |
| 93 |
"outcome": { |
| 94 |
"result": { |
| 95 |
"matchedCount": 0, |
| 96 |
"modifiedCount": 0, |
| 97 |
"upsertedCount": 0 |
| 98 |
}, |
| 99 |
"collection": { |
| 100 |
"data": [ |
| 101 |
{ |
| 102 |
"_id": 1, |
| 103 |
"x": 11 |
| 104 |
}, |
| 105 |
{ |
| 106 |
"_id": 2, |
| 107 |
"x": 22 |
| 108 |
}, |
| 109 |
{ |
| 110 |
"_id": 3, |
| 111 |
"x": 33 |
| 112 |
} |
| 113 |
] |
| 114 |
} |
| 115 |
} |
| 116 |
}, |
| 117 |
{ |
| 118 |
"description": "ReplaceOne with upsert when no documents match without an id specified", |
| 119 |
"operation": { |
| 120 |
"name": "replaceOne", |
| 121 |
"arguments": { |
| 122 |
"filter": { |
| 123 |
"_id": 4 |
| 124 |
}, |
| 125 |
"replacement": { |
| 126 |
"x": 1 |
| 127 |
}, |
| 128 |
"upsert": true |
| 129 |
} |
| 130 |
}, |
| 131 |
"outcome": { |
| 132 |
"result": { |
| 133 |
"matchedCount": 0, |
| 134 |
"modifiedCount": 0, |
| 135 |
"upsertedCount": 1, |
| 136 |
"upsertedId": 4 |
| 137 |
}, |
| 138 |
"collection": { |
| 139 |
"data": [ |
| 140 |
{ |
| 141 |
"_id": 1, |
| 142 |
"x": 11 |
| 143 |
}, |
| 144 |
{ |
| 145 |
"_id": 2, |
| 146 |
"x": 22 |
| 147 |
}, |
| 148 |
{ |
| 149 |
"_id": 3, |
| 150 |
"x": 33 |
| 151 |
}, |
| 152 |
{ |
| 153 |
"_id": 4, |
| 154 |
"x": 1 |
| 155 |
} |
| 156 |
] |
| 157 |
} |
| 158 |
} |
| 159 |
}, |
| 160 |
{ |
| 161 |
"description": "ReplaceOne with upsert when no documents match with an id specified", |
| 162 |
"operation": { |
| 163 |
"name": "replaceOne", |
| 164 |
"arguments": { |
| 165 |
"filter": { |
| 166 |
"_id": 4 |
| 167 |
}, |
| 168 |
"replacement": { |
| 169 |
"_id": 4, |
| 170 |
"x": 1 |
| 171 |
}, |
| 172 |
"upsert": true |
| 173 |
} |
| 174 |
}, |
| 175 |
"outcome": { |
| 176 |
"result": { |
| 177 |
"matchedCount": 0, |
| 178 |
"modifiedCount": 0, |
| 179 |
"upsertedCount": 1, |
| 180 |
"upsertedId": 4 |
| 181 |
}, |
| 182 |
"collection": { |
| 183 |
"data": [ |
| 184 |
{ |
| 185 |
"_id": 1, |
| 186 |
"x": 11 |
| 187 |
}, |
| 188 |
{ |
| 189 |
"_id": 2, |
| 190 |
"x": 22 |
| 191 |
}, |
| 192 |
{ |
| 193 |
"_id": 3, |
| 194 |
"x": 33 |
| 195 |
}, |
| 196 |
{ |
| 197 |
"_id": 4, |
| 198 |
"x": 1 |
| 199 |
} |
| 200 |
] |
| 201 |
} |
| 202 |
} |
| 203 |
} |
| 204 |
] |
| 205 |
} |