Skip to content

Commit

Permalink
MOTOR-940 Improved Bulk Write API (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Aug 21, 2024
1 parent 99cc1b5 commit 00f27f3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions motor/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class AgnosticClient(AgnosticBaseProperties):
arbiters = ReadOnlyProperty()
close = DelegateMethod()
__hash__ = DelegateMethod()
bulk_write = AsyncRead()
drop_database = AsyncCommand().unwrap("MotorDatabase")
options = ReadOnlyProperty()
get_database = DelegateMethod(doc=docstrings.get_database_doc).wrap(Database)
Expand Down
12 changes: 12 additions & 0 deletions motor/core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ from pymongo.read_concern import ReadConcern
from pymongo.read_preferences import _ServerMode
from pymongo.results import (
BulkWriteResult,
ClientBulkWriteResult,
DeleteResult,
InsertManyResult,
InsertOneResult,
Expand Down Expand Up @@ -124,6 +125,17 @@ class AgnosticClient(AgnosticBaseProperties[_DocumentType]):
write_concern: Optional[WriteConcern] = None,
read_concern: Optional[ReadConcern] = None,
) -> AgnosticDatabase[_DocumentType]: ...
async def bulk_write(
self,
models: Sequence[_WriteOp[_DocumentType]],
session: Optional[ClientSession] = None,
ordered: bool = True,
verbose_results: bool = False,
bypass_document_validation: Optional[bool] = None,
comment: Optional[Any] = None,
let: Optional[Mapping] = None,
write_concern: Optional[WriteConcern] = None,
) -> ClientBulkWriteResult: ...

HOST: str

Expand Down
1 change: 1 addition & 0 deletions synchro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
from pymongo.srv_resolver import _resolve, _SrvResolver
from pymongo.ssl_support import *
from pymongo.synchronous.client_session import _TxnState
from pymongo.synchronous.encryption import _Encrypter
from pymongo.synchronous.monitor import *
from pymongo.synchronous.periodic_executor import *
from pymongo.synchronous.periodic_executor import _EXECUTORS
Expand Down
2 changes: 1 addition & 1 deletion test/tornado_tests/test_motor_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def attrs(klass):

motor_client_only = motor_only.union(["open"])

pymongo_client_only = set(["bulk_write"]).union(pymongo_only)
pymongo_client_only = set([]).union(pymongo_only)

pymongo_database_only = set([]).union(pymongo_only)

Expand Down

0 comments on commit 00f27f3

Please sign in to comment.