Create a replace document and add it to the list of ops.
(
self,
namespace: str,
selector: Mapping[str, Any],
replacement: Mapping[str, Any],
upsert: Optional[bool] = None,
collation: Optional[Mapping[str, Any]] = None,
hint: Union[str, dict[str, Any], None] = None,
sort: Optional[Mapping[str, Any]] = None,
)
| 173 | self.total_ops += 1 |
| 174 | |
| 175 | def add_replace( |
| 176 | self, |
| 177 | namespace: str, |
| 178 | selector: Mapping[str, Any], |
| 179 | replacement: Mapping[str, Any], |
| 180 | upsert: Optional[bool] = None, |
| 181 | collation: Optional[Mapping[str, Any]] = None, |
| 182 | hint: Union[str, dict[str, Any], None] = None, |
| 183 | sort: Optional[Mapping[str, Any]] = None, |
| 184 | ) -> None: |
| 185 | """Create a replace document and add it to the list of ops.""" |
| 186 | validate_ok_for_replace(replacement) |
| 187 | cmd = { |
| 188 | "update": -1, |
| 189 | "filter": selector, |
| 190 | "updateMods": replacement, |
| 191 | "multi": False, |
| 192 | } |
| 193 | if upsert is not None: |
| 194 | cmd["upsert"] = upsert |
| 195 | if hint is not None: |
| 196 | cmd["hint"] = hint |
| 197 | if collation is not None: |
| 198 | self.uses_collation = True |
| 199 | cmd["collation"] = collation |
| 200 | if sort is not None: |
| 201 | cmd["sort"] = sort |
| 202 | self.ops.append(("replace", cmd)) |
| 203 | self.namespaces.append(namespace) |
| 204 | self.total_ops += 1 |
| 205 | |
| 206 | def add_delete( |
| 207 | self, |
nothing calls this directly
no test coverage detected