Skip to content

Commit

Permalink
Updated docs include syntax for /docs/tutorial/fastapi/teams.md
Browse files Browse the repository at this point in the history
  • Loading branch information
immortalcodes authored Nov 14, 2024
1 parent e86b5fc commit 20c6531
Showing 1 changed file with 4 additions and 246 deletions.
250 changes: 4 additions & 246 deletions docs/tutorial/fastapi/teams.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,133 +18,15 @@ Then we also inherit from the `TeamBase` for the `TeamCreate` and `TeamPublic` *

And we also create a `TeamUpdate` **data model**.

//// tab | Python 3.10+

```Python hl_lines="5-7 10-13 16-17 20-21 24-26"
{!./docs_src/tutorial/fastapi/teams/tutorial001_py310.py[ln:1-26]!}

# Code below omitted 👇
```

////

//// tab | Python 3.9+

```Python hl_lines="7-9 12-15 18-19 22-23 26-28"
{!./docs_src/tutorial/fastapi/teams/tutorial001_py39.py[ln:1-28]!}

# Code below omitted 👇
```

////

//// tab | Python 3.7+

```Python hl_lines="7-9 12-15 18-19 22-23 26-28"
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:1-28]!}

# Code below omitted 👇
```

////

/// details | 👀 Full file preview

//// tab | Python 3.10+

```Python
{!./docs_src/tutorial/fastapi/teams/tutorial001_py310.py!}
```

////

//// tab | Python 3.9+

```Python
{!./docs_src/tutorial/fastapi/teams/tutorial001_py39.py!}
```

////

//// tab | Python 3.7+

```Python
{!./docs_src/tutorial/fastapi/teams/tutorial001.py!}
```

////

///
{* ./docs_src/tutorial/fastapi/teams/tutorial001_py310.py ln[1:26] hl[5:7,10:13,16:17,20:21,24:26] *}

We now also have **relationship attributes**. 🎉

Let's now update the `Hero` models too.

## Update Hero Models

//// tab | Python 3.10+

```Python hl_lines="3-8 11-14 17-18 21-22 25-29"
# Code above omitted 👆

{!./docs_src/tutorial/fastapi/teams/tutorial001_py310.py[ln:29-55]!}

# Code below omitted 👇
```

////

//// tab | Python 3.9+

```Python hl_lines="3-8 11-14 17-18 21-22 25-29"
# Code above omitted 👆

{!./docs_src/tutorial/fastapi/teams/tutorial001_py39.py[ln:31-57]!}

# Code below omitted 👇
```

////

//// tab | Python 3.7+

```Python hl_lines="3-8 11-14 17-18 21-22 25-29"
# Code above omitted 👆

{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:31-57]!}

# Code below omitted 👇
```

////

/// details | 👀 Full file preview

//// tab | Python 3.10+

```Python
{!./docs_src/tutorial/fastapi/teams/tutorial001_py310.py!}
```

////

//// tab | Python 3.9+

```Python
{!./docs_src/tutorial/fastapi/teams/tutorial001_py39.py!}
```

////

//// tab | Python 3.7+

```Python
{!./docs_src/tutorial/fastapi/teams/tutorial001.py!}
```

////

///
{* ./docs_src/tutorial/fastapi/teams/tutorial001_py310.py ln[29:55] hl[29:34,37:40,43:44,47:48,51:55] *}

We now have a `team_id` in the hero models.

Expand All @@ -156,139 +38,15 @@ And even though the `HeroBase` is *not* a **table model**, we can declare `team_

Notice that the **relationship attributes**, the ones with `Relationship()`, are **only** in the **table models**, as those are the ones that are handled by **SQLModel** with SQLAlchemy and that can have the automatic fetching of data from the database when we access them.

//// tab | Python 3.10+

```Python hl_lines="11 38"
# Code above omitted 👆

{!./docs_src/tutorial/fastapi/teams/tutorial001_py310.py[ln:5-55]!}

# Code below omitted 👇
```

////

//// tab | Python 3.9+

```Python hl_lines="11 38"
# Code above omitted 👆

{!./docs_src/tutorial/fastapi/teams/tutorial001_py39.py[ln:7-57]!}

# Code below omitted 👇
```

////

//// tab | Python 3.7+

```Python hl_lines="11 38"
# Code above omitted 👆

{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:7-57]!}

# Code below omitted 👇
```

////

/// details | 👀 Full file preview

//// tab | Python 3.10+

```Python
{!./docs_src/tutorial/fastapi/teams/tutorial001_py310.py!}
```

////

//// tab | Python 3.9+

```Python
{!./docs_src/tutorial/fastapi/teams/tutorial001_py39.py!}
```

////

//// tab | Python 3.7+

```Python
{!./docs_src/tutorial/fastapi/teams/tutorial001.py!}
```

////

///
{* ./docs_src/tutorial/fastapi/teams/tutorial001_py310.py ln[5:55] hl[13,40] *}

## Path Operations for Teams

Let's now add the **path operations** for teams.

These are equivalent and very similar to the **path operations** for the **heroes** we had before, so we don't have to go over the details for each one, let's check the code.

//// tab | Python 3.10+

```Python hl_lines="3-9 12-20 23-28 31-47 50-57"
# Code above omitted 👆

{!./docs_src/tutorial/fastapi/teams/tutorial001_py310.py[ln:136-190]!}

# Code below omitted 👇
```

////

//// tab | Python 3.9+

```Python hl_lines="3-9 12-20 23-28 31-47 50-57"
# Code above omitted 👆

{!./docs_src/tutorial/fastapi/teams/tutorial001_py39.py[ln:138-192]!}

# Code below omitted 👇
```

////

//// tab | Python 3.7+

```Python hl_lines="3-9 12-20 23-28 31-47 50-57"
# Code above omitted 👆

{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:138-192]!}

# Code below omitted 👇
```

////

/// details | 👀 Full file preview

//// tab | Python 3.10+

```Python
{!./docs_src/tutorial/fastapi/teams/tutorial001_py310.py!}
```

////

//// tab | Python 3.9+

```Python
{!./docs_src/tutorial/fastapi/teams/tutorial001_py39.py!}
```

////

//// tab | Python 3.7+

```Python
{!./docs_src/tutorial/fastapi/teams/tutorial001.py!}
```

////

///
{* ./docs_src/tutorial/fastapi/teams/tutorial001_py310.py ln[136:190] hl[136:142,145:153,156:161,164:180,183:190] *}

## Using Relationships Attributes

Expand Down

0 comments on commit 20c6531

Please sign in to comment.