Skip to content

Commit e538102

Browse files
committed
fixed docs
1 parent 80e185b commit e538102

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ user = await crud_users.get_multi(
589589
)
590590
```
591591

592-
To create, you pass a `CreateSchemaType` object with the attributes, such as a `CreateUser` pydantic schema:
592+
To create, you pass a `CreateSchemaType` object with the attributes, such as a `UserCreate` pydantic schema:
593593
```python
594594
from app.core.schemas.user import UserCreate
595595

@@ -606,14 +606,16 @@ crud_users.create(db=db, object=user_internal)
606606

607607
To just check if there is at least one row that matches a certain set of attributes, you should use `exists`
608608
```python
609-
# This queries only the email variable, and returns True if there's at least one or False if there is none
609+
# This queries only the email variable
610+
# It returns True if there's at least one or False if there is none
610611
crud_users.exists(db=db, email=user@example.com)
611612
```
612613

613614
To update you pass an `object` which may be a `pydantic schema` or just a regular `dict`, and the kwargs.
614615
You will update with `objects` the rows that match your `kwargs`.
615616
```python
616-
# Here I'm updating the user with username == "myusername". I'll change his name to "Updated Name"
617+
# Here I'm updating the user with username == "myusername".
618+
# #I'll change his name to "Updated Name"
617619
crud_users.update(db=db, object={name="Updated Name"}, username="myusername")
618620
```
619621

@@ -631,14 +633,15 @@ crud_users.delete(db=db, username="myusername")
631633
crud_users.db_delete(db=db, username="myusername")
632634
```
633635

634-
#### Advanced - Efficient Get
636+
#### More Efficient Selecting
635637
For the `get` and `get_multi` methods we have the option to define a `schema_to_select` attribute, which is what actually makes the queries more efficient. When you pass a pydantic schema in `schema_to_select` to the `get` or `get_multi` methods, only the attributes in the schema will be selected.
636638
```python
637639
from app.schemas.user import UserRead
638-
# Here it's selecting all of the user's data, but maybe I just need what I'll return, the UserRead
640+
# Here it's selecting all of the user's data
639641
crud_user.get(db=db, username="myusername")
640642

641-
# Now it's only selecting the data that is in UserRead. Since that's my response_model, it's all I need
643+
# Now it's only selecting the data that is in UserRead.
644+
# Since that's my response_model, it's all I need
642645
crud_user.get(db=db, username="myusername", schema_to_select=UserRead)
643646
```
644647

0 commit comments

Comments
 (0)