Skip to content

Conversation

@PenguinBoi12
Copy link
Contributor

@PenguinBoi12 PenguinBoi12 commented Sep 28, 2025

This PR is a major refactor of the Model and query system. It adds SQLModel, which is similar to our current Model, and includes a QueryBuilder on top of it to provide an API closer to Active Record or Eloquent.

Here's an example of grace's thread model:

# bot/models/extensions/thread.py
from grace.model import Model, Field, Column, Text, Integer


class Thread(Model):
    __tablename__ = 'threads'  # only needed because for old tables
    
    id: int | None = Field(default=None, primary_key=True)
    title: str
    content: str = Field(sa_type=Text)
    recurrence: Recurrence = Field(sa_column=Column(Integer))
thread = Thread.create(
    title="Daily Standup",
    content="Long content here...",
    recurrence=Recurrence.DAILY
)

daily_threads = Thread.where(Thread.recurrence == Recurrence.DAILY).all()
thread_by_id = Thread.find(1)

thread.recurrence = Recurrence.WEEKLY
thread.save()

@PenguinBoi12 PenguinBoi12 changed the title Improvement of the ORM WIP: Improvement of the ORM Sep 28, 2025
@PenguinBoi12 PenguinBoi12 merged commit bfe8dce into main Oct 13, 2025
2 checks passed
@PenguinBoi12 PenguinBoi12 deleted the improved-orm branch October 13, 2025 03:25
@PenguinBoi12 PenguinBoi12 changed the title WIP: Improvement of the ORM Improvement of the ORM Dec 9, 2025
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.

2 participants