You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/migration/08_to_10.md
+38Lines changed: 38 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,20 @@ class Model(BaseModel):
32
32
user_id: UUID4
33
33
```
34
34
35
+
#### MongoDB
36
+
37
+
To avoid any issues, it's recommended to use the `standard` UUID representation when instantiating the MongoDB client:
38
+
39
+
```py
40
+
DATABASE_URL="mongodb://localhost:27017"
41
+
client = motor.motor_asyncio.AsyncIOMotorClient(
42
+
DATABASE_URL, uuidRepresentation="standard"
43
+
)
44
+
```
45
+
46
+
This parameter controls how the UUID values will be encoded in the database. By default, it's set to `pythonLegacy` but new applications should consider setting this to `standard` for cross language compatibility. [Read more about this](https://pymongo.readthedocs.io/en/stable/api/pymongo/mongo_client.html#pymongo.mongo_client.MongoClient).
47
+
48
+
35
49
### In database
36
50
37
51
Id. were before stored as strings in the database. You should make a migration to convert string data to UUID data.
@@ -72,6 +86,8 @@ ALTER TABLE "user" MODIFY id CHAR(36);
72
86
73
87
#### MongoDB
74
88
89
+
##### Mongo shell
90
+
75
91
For MongoDB, we can use a `forEach` iterator to convert the id. for each document:
0 commit comments