@@ -7,7 +7,7 @@ Migrate to the {+driver-async+} Driver
7
7
.. contents:: On this page
8
8
:local:
9
9
:backlinks: none
10
- :depth: 1
10
+ :depth: 2
11
11
:class: singlecol
12
12
13
13
.. facet::
@@ -23,12 +23,12 @@ Overview
23
23
The {+driver-async+} driver is a unification of {+driver-short+} and the `Motor
24
24
library <https://www.mongodb.com/docs/drivers/motor/>`__. In this guide, you can
25
25
identify the changes you must make to migrate an application from
26
- {+driver-short+} or from Motor to the {+driver-async+} driver.
26
+ {+driver-short+} or Motor to the {+driver-async+} driver.
27
27
28
28
Migrate From {+driver-short+}
29
29
--------------------
30
30
31
- The {+driver-async+} driver behaves nearly identically to {+driver-short+}, but
31
+ The {+driver-async+} driver behaves similarly to {+driver-short+}, but
32
32
all methods that perform network operations are coroutines and must be awaited.
33
33
To migrate from {+driver-short+} to {+driver-async+}, you must update your code
34
34
to replace all uses of ``MongoClient`` with ``AsyncMongoClient`` and add the
@@ -61,7 +61,7 @@ Client Methods
61
61
- .. code-block:: python
62
62
63
63
async with await client.watch(...) as stream:
64
- ...
64
+ ...
65
65
66
66
* - ``server_info()``
67
67
- .. code-block:: python
@@ -108,8 +108,7 @@ Database Methods
108
108
- .. code-block:: python
109
109
110
110
async with await client.admin.aggregate(...) as cursor:
111
- async for operation in cursor:
112
- print(operation)
111
+ ...
113
112
114
113
* - ``command()``
115
114
- .. code-block:: python
@@ -281,11 +280,13 @@ Collection Methods
281
280
- .. code-block:: python
282
281
283
282
async for doc in await collection.aggregate(...):
283
+ ...
284
284
285
285
* - ``aggregate_raw_batches()``
286
286
- .. code-block:: python
287
287
288
288
async for batch in await collection.aggregate_raw_batches(...):
289
+ ...
289
290
290
291
* - ``rename()``
291
292
- .. code-block:: python
@@ -320,8 +321,8 @@ most cases, you can directly migrate existing Motor applications to
320
321
{+driver-short+}, changing only the application's import statements, and
321
322
by using ``AsyncMongoClient`` in place of ``MotorClient``.
322
323
323
- The following section details Motor method signatures that the
324
- {+driver-async+} changes :
324
+ The following section shows the method signature changes that you must make when
325
+ migrating from Motor to the {+driver-async+} driver :
325
326
326
327
Method Signature Changes
327
328
~~~~~~~~~~~~~~~~~~~~~~~~
0 commit comments