MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / add_replace

Method add_replace

pymongo/synchronous/bulk.py:172–195  ·  view source on GitHub ↗

Create a replace document and add it to the list of ops.

(
        self,
        selector: Mapping[str, Any],
        replacement: Mapping[str, Any],
        upsert: Optional[bool],
        collation: Optional[Mapping[str, Any]] = None,
        hint: Union[str, dict[str, Any], None] = None,
        sort: Optional[Mapping[str, Any]] = None,
    )

Source from the content-addressed store, hash-verified

170 self.ops.append((_UPDATE, cmd))
171
172 def add_replace(
173 self,
174 selector: Mapping[str, Any],
175 replacement: Mapping[str, Any],
176 upsert: Optional[bool],
177 collation: Optional[Mapping[str, Any]] = None,
178 hint: Union[str, dict[str, Any], None] = None,
179 sort: Optional[Mapping[str, Any]] = None,
180 ) -> None:
181 """Create a replace document and add it to the list of ops."""
182 validate_ok_for_replace(replacement)
183 cmd: dict[str, Any] = {"q": selector, "u": replacement}
184 if upsert is not None:
185 cmd["upsert"] = upsert
186 if collation is not None:
187 self.uses_collation = True
188 cmd["collation"] = collation
189 if hint is not None:
190 self.uses_hint_update = True
191 cmd["hint"] = hint
192 if sort is not None:
193 self.uses_sort = True
194 cmd["sort"] = sort
195 self.ops.append((_UPDATE, cmd))
196
197 def add_delete(
198 self,

Callers 2

_add_to_bulkMethod · 0.45
_add_to_client_bulkMethod · 0.45

Calls 1

validate_ok_for_replaceFunction · 0.90

Tested by

no test coverage detected