Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added SerializableModel for being able to serialize any model #95

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aminiun
Copy link
Contributor

@aminiun aminiun commented Jun 25, 2024

Sample 1:

# Model
class User(SerializableModel, Base):
    __tablename__ = "user_account"

    id: Mapped[int] = mapped_column(primary_key=True)
    name: Mapped[str] = mapped_column(String(30))

API Response:

[{"id":1,"name":"a"},{"id":2,"name":"b"}]

Sample 2:

# Model
class User(SerializableModel, Base):
    __tablename__ = "user_account"

    serializable_fields = (
        "name",
    )

    id: Mapped[int] = mapped_column(primary_key=True)
    name: Mapped[str] = mapped_column(String(30))

API Response:

[{"name":"a"},{"name":"b"}]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant