README and some fixes

This commit is contained in:
2025-05-27 13:09:50 +03:00
parent 6055467e97
commit cedb471722
5 changed files with 25 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
from typing import Optional, List
from typing import List
from sqlmodel import SQLModel, Field, Relationship
# Relationship model
@@ -8,14 +8,14 @@ class AuthorBookLink(SQLModel, table=True):
# Author model
class Author(SQLModel, table=True):
id: Optional[int] = Field(primary_key=True, index=True)
id: int | None = Field(primary_key=True, index=True)
name: str
books: List["Book"] = Relationship(back_populates="authors", link_model=AuthorBookLink)
# Book model
class Book(SQLModel, table=True):
id: Optional[int] = Field(primary_key=True, index=True)
id: int | None = Field(primary_key=True, index=True)
title: str
description: str
authors: List[Author] = Relationship(back_populates="books", link_model=AuthorBookLink)