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

Use tree-like API for foreign keys. #9

Closed
aebrahim opened this issue Feb 3, 2022 · 2 comments
Closed

Use tree-like API for foreign keys. #9

aebrahim opened this issue Feb 3, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@aebrahim
Copy link
Contributor

aebrahim commented Feb 3, 2022

This is such a cool package, but I ended up not using it because I wanted my API to look like this. I thought I would just leave it as a suggestion.

Suppose I have this in sqlalchemy:

import sqlalchemy as sa

class Account(Base):
    __tablename__ = "account"
    id = sa.Column(sa.Integer, primary_key=True, autoincrement=True)

class BlogPost(Base):
    __tablename__ = "blog_post"
    id = sa.Column(sa.Integer, primary_key=True, autoincrement=True)
    account_id = sa.Column(sa.Integer, sa.ForeignKey("account.id"), nullable=False)

class BlogComment(Base)
    __tablename__ = "blog_comment"
    id = sa.Column(sa.Integer, primary_key=True, autoincrement=True)
    blog_id = sa.Column(sa.Integer, sa.ForeignKey("blog_post.id"), nullable=False)

I might want routes like this:

GET /account/<account_id>/post/
{ list of blog posts by the author }
POST /account/<account_id>/post/
# creates a new blog post for the author
GET /post/<post_id>/comment
{ list of comments on the blog post }
GET /account<account_id>/post/<post_id>/comment
{ list of comments on the blog post - not sure how this is compared to the one above }

Anyways, just a thought!

@LuisLuii
Copy link
Owner

LuisLuii commented Feb 4, 2022

Hi aebrahim, Thanks so much for your contribution and suggestion, the suggestion is great. I will plan to enhance the package with your suggestion. And will update here

@LuisLuii LuisLuii added the enhancement New feature or request label Feb 7, 2022
@LuisLuii
Copy link
Owner

LuisLuii commented Feb 13, 2022

Let discuss this feature in #11, Thanks

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

No branches or pull requests

2 participants