Skip to content

Commit bf73838

Browse files
committed
edit
1 parent 8167f78 commit bf73838

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

source/integrations/fastapi-integration.txt

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,19 @@ FastAPI Integration and Tutorial
1919
:description: Learn how to create an app to connect to MongoDB deployment by using the PyMongo driver.
2020
:keywords: quick start, tutorial, basics
2121

22+
Overview
23+
--------
24+
2225
`FastAPI <https://fastapi.tiangolo.com/>`__ is a high-performance,
2326
production-ready asynchronous Python framework for building APIs based on
2427
standard Python type hints. In this tutorial, we will create a CRUD application
2528
showing how you can integrate MongoDB with your FastAPI projects.
2629

27-
Mapping
28-
-------
29-
30-
The _id Attribute and ObjectIds
31-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32-
33-
FastAPI encodes and decodes data as JSON strings, which do not support all of the
34-
data types that MongoDB's BSON data type can store. BSON has support for
35-
additional non-JSON-native data types, including ``ObjectId`` which is used for
36-
the default UUID attribute, ``_id``. Because of this, you must convert ``ObjectId``s to
37-
strings before storing them in the ``id`` field.
38-
39-
For for information about how BSON compares to JSON, see this `JSON and BSON
40-
<https://www.mongodb.com/json-and-bson>`__ MongoDB article.
41-
42-
Database Models
43-
~~~~~~~~~~~~~~~
44-
45-
MongoDB collections do not enforce document structure by default, so you have the flexibility to make whatever data-modelling choices best match your application and its performance requirements. So, it's not unusual to create models when working with a MongoDB database.
46-
4730
Tutorial
4831
--------
4932

33+
This tutorial walks through the `MongoDB with FastAPI sample project <https://github.com/mongodb-developer/mongodb-with-fastapi>`__.
34+
5035
Prerequisites
5136
~~~~~~~~~~~~~
5237

@@ -122,6 +107,17 @@ Connect to your MongoDB Atlas cluster using the asynchronous `Pymongo Driver <ht
122107

123108
Define Your Database Models
124109
~~~~~~~~~~~~~~~~~~~~~~~~~~~
110+
111+
.. note:: BSON to JSON Mapping
112+
113+
FastAPI encodes and decodes data as JSON strings, which do not support all of the
114+
data types that MongoDB's BSON data type can store. BSON has support for
115+
additional non-JSON-native data types, including ``ObjectId`` which is used for
116+
the default UUID attribute, ``_id``. Because of this, you must convert
117+
``ObjectId`` objects to strings before storing them in the ``_id`` field.
118+
119+
For more information about how BSON compares to JSON, see this `JSON and BSON
120+
<https://www.mongodb.com/json-and-bson>`__ MongoDB article.
125121

126122
Our application has three models, the ``StudentModel``, the ``UpdateStudentModel``, and the ``StudentCollection``.
127123

@@ -380,10 +376,11 @@ More Resources
380376

381377
For more information, see the following resources:
382378

383-
- Full Stack FastAPI App Generator:
379+
- MongoDB's Full Stack FastAPI App Generator:
384380
- `Blog post: Introducing the Full Stack FastAPI App Generator for Python Developers <https://www.mongodb.com/blog/post/introducing-full-stack-fast-api-app-generator-for-python-developers>`__
385381
- `Github repository: full-stack-fastapi-mongodb <https://github.com/mongodb-labs/full-stack-fastapi-mongodb>`__
386382
- `Introducing the FARM stack (FastAPI, React and MongoDB) blog post <https://developer.mongodb.com/how-to/FARM-Stack-FastAPI-React-MongoDB>`__
387-
- `FastAPI documentation <https://motor.readthedocs.io>`__
383+
- `FastAPI documentation <https://fastapi.tiangolo.com/>`__
388384
- `Third-party FastAPI Integration Options <https://github.com/mjhea0/awesome-fastapi>`__
389-
- `MongoDB Developer Community <https://community.mongodb.com/>`__
385+
386+
For support or to contribute to the MongoDB Community, see the `MongoDB Developer Community <https://community.mongodb.com/>`__.

0 commit comments

Comments
 (0)