Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
jefersondaniel committed Apr 25, 2024
1 parent 1efc602 commit bbc6efc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ pip install pydantic-mongo
```python
from bson import ObjectId
from pydantic import BaseModel
from pydantic_mongo import AbstractRepository, ObjectIdField
from pydantic_mongo import AbstractRepository, PydanticObjectId
from pymongo import MongoClient
from typing import List
from typing import Optional, List
import os

class Foo(BaseModel):
Expand All @@ -31,7 +31,7 @@ class Bar(BaseModel):
banana: str = 'y'

class Spam(BaseModel):
id: ObjectIdField = None
id: Optional[PydanticObjectId] = None
foo: Foo
bars: List[Bar]

Expand Down Expand Up @@ -64,7 +64,7 @@ spam_repository.delete(spam)
# Find One By Id
result = spam_repository.find_one_by_id(spam.id)

# Find One By Id using string if the id attribute is a ObjectIdField
# Find One By Id using string if the id attribute is a PydanticObjectId
result = spam_repository.find_one_by_id(ObjectId('611827f2878b88b49ebb69fc'))
assert result.foo.count == 2

Expand Down
2 changes: 1 addition & 1 deletion test/test_repository.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Annotated, List, Optional, cast
from typing import List, Optional, cast

import mongomock
import pytest
Expand Down

0 comments on commit bbc6efc

Please sign in to comment.