Create an update document and add it to the list of ops.
(
self,
selector: Mapping[str, Any],
update: Union[Mapping[str, Any], _Pipeline],
multi: bool,
upsert: Optional[bool],
collation: Optional[Mapping[str, Any]] = None,
array_filters: Optional[list[Mapping[str, Any]]] = None,
hint: Union[str, dict[str, Any], None] = None,
sort: Optional[Mapping[str, Any]] = None,
)
| 137 | self.ops.append((_INSERT, document)) |
| 138 | |
| 139 | def add_update( |
| 140 | self, |
| 141 | selector: Mapping[str, Any], |
| 142 | update: Union[Mapping[str, Any], _Pipeline], |
| 143 | multi: bool, |
| 144 | upsert: Optional[bool], |
| 145 | collation: Optional[Mapping[str, Any]] = None, |
| 146 | array_filters: Optional[list[Mapping[str, Any]]] = None, |
| 147 | hint: Union[str, dict[str, Any], None] = None, |
| 148 | sort: Optional[Mapping[str, Any]] = None, |
| 149 | ) -> None: |
| 150 | """Create an update document and add it to the list of ops.""" |
| 151 | validate_ok_for_update(update) |
| 152 | cmd: dict[str, Any] = {"q": selector, "u": update, "multi": multi} |
| 153 | if upsert is not None: |
| 154 | cmd["upsert"] = upsert |
| 155 | if collation is not None: |
| 156 | self.uses_collation = True |
| 157 | cmd["collation"] = collation |
| 158 | if array_filters is not None: |
| 159 | self.uses_array_filters = True |
| 160 | cmd["arrayFilters"] = array_filters |
| 161 | if hint is not None: |
| 162 | self.uses_hint_update = True |
| 163 | cmd["hint"] = hint |
| 164 | if sort is not None: |
| 165 | self.uses_sort = True |
| 166 | cmd["sort"] = sort |
| 167 | if multi: |
| 168 | # A bulk_write containing an update_many is not retryable. |
| 169 | self.is_retryable = False |
| 170 | self.ops.append((_UPDATE, cmd)) |
| 171 | |
| 172 | def add_replace( |
| 173 | self, |
no test coverage detected