Skip to content

Commit c29250e

Browse files
draft start
1 parent 15d8174 commit c29250e

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

snooty.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/"
2424
[constants]
2525
driver-short = "PyMongo"
2626
driver-long = "PyMongo, the MongoDB synchronous Python driver,"
27+
driver-async = "Pymongo Async"
2728
language = "Python"
2829
mdb-server = "MongoDB Server"
2930
mongo-community = "MongoDB Community Edition"

source/index.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ MongoDB {+driver-short+} Documentation
2626
/troubleshooting
2727
/whats-new
2828
/upgrade
29+
/motor-async-migration
2930
/previous-versions
3031
/issues-and-help
3132
/compatibility
@@ -120,6 +121,12 @@ Upgrade {+driver-short+} Versions
120121
Learn what changes you might need to make to your application to upgrade driver versions
121122
in the :ref:`pymongo-upgrade` section.
122123

124+
Migrate From Motor to {+driver-async+}
125+
------------------------------------
126+
127+
Learn how to migrate your Motor application to {+driver-async+} in the
128+
:ref:`pymongo-motor-to-async` section.
129+
123130
Previous Versions
124131
-----------------
125132

source/motor-async-migration.txt

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
.. _pymongo-motor-to-async:
2+
3+
===================================
4+
Migrate from Motor to {+driver-async+}
5+
===================================
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
.. facet::
14+
:name: genre
15+
:values: reference
16+
17+
.. meta::
18+
:keywords: motor, async, refactor, migration
19+
20+
Overview
21+
--------
22+
23+
The {+driver-async+} is a unification of {+driver-short+} and the Motor library.
24+
In this guide, you can identify the changes you must make to migrate an
25+
application from Motor to {+driver-async+}.
26+
27+
Prerequisites
28+
-------------
29+
30+
To migrate from Motor to {+driver-async+}, you must first complete the following
31+
steps:
32+
33+
1. Upgrade Motor to v3.6.
34+
#. Run your application to identify any warnings or errors.
35+
#. Update your application to remove all warnings and errors.
36+
#. Update any imports in your application that import from the ``motor`` library
37+
to instead import from ``pymongo.asynchronous``.
38+
39+
API Changes
40+
-----------
41+
42+
To use the following collection method calls, you must wrap them in an ``await``
43+
statement:
44+
45+
- ``aggregate()``
46+
- ``aggregate_raw_batches()``
47+
- ``watch()``
48+
- ``list_indexes()``
49+
- ``list_search_indexes()``
50+
51+
The following example demonstrates how to call the ``list_search_indexes()`` method with
52+
{+driver-async+}:
53+
54+
.. code-block:: python
55+
56+
results = await collection.list_search_indexes()
57+
58+
The following methods are not asynchronous in {+driver-async+}:
59+
60+
- ``MongoClient.start_session()``
61+
62+
The following methods are asynchronous in {+driver-async+}:
63+
64+
- ``AsyncClientSession.start_transaction()``
65+
- ``Cursor.rewind()``
66+
67+
Method Signature Changes
68+
------------------------
69+
70+
The following method signatures are changed in {+driver-async+}:
71+
72+
- ``GridOut.open()`` now returns ``None``.
73+
- ``AsyncMongoClient.__init__`` no longer accepts an ``io_loop`` parameter.
74+
- ``Gridln.set()`` does not accept a filename. Instead pass a file name by using the
75+
``Gridln.filename`` attribute.
76+
- ``Cursor.each()`` is removed.
77+
- ``to_list(0)`` is no longer valid. Use ``to_list(None)`` instead.

0 commit comments

Comments
 (0)