On the query of many-to-many tables in flask sqlalchemy

I want to implement the function of , which returns all questions under all tags that the user follows and sorts them in chronological order.

Tag and Question are many-to-many, User and Question are one-to-many, and user and tag are many-to-many

I used db.Table to implement many-to-many directly before, but now I change the association table into a FollowTag model according to the dog book, and I don"t understand join query all the time. How can I achieve this function? Thank you! ?

class FollowTag(db.Model):
    tag_id = db.Column(db.Integer, db.ForeignKey("tag.id"),
                       primary_key=True)
    question_id = db.Column(db.Integer, db.ForeignKey("question.id"),
                            primary_key=True)
    create_time = db.Column(db.DateTime, default=datetime.utcnow)

solved
just use db.Table

  https://github.com/eastossifr...

Menu