3

我有以下实体。当我这样做时api/event/1,我会得到invitation包括在内,但不是invitationResponses. 如果以及如何实现这一目标?当我这样做时api/invitation/1,邀请响应包括在内。

class Person(db.Model):
    id = db.Column(db.Integer, primary_key = True)
    name = db.Column(db.String(64), index = True)
    owner = db.Column(db.Integer, db.ForeignKey('user.id'))
    description = db.Column(db.String(128))
    start = db.Column(db.DateTime)
    end = db.Column(db.DateTime)
    invitation = db.relationship('Invitation', uselist=False, backref =      db.backref('event', uselist=False))


class Invitation(db.Model):
    id = db.Column(db.Integer, primary_key = True)
    event_id = db.Column(db.Integer, db.ForeignKey('event.id'))
    sent = db.Column(db.DateTime)
    expires = db.Column(db.DateTime)
    invitationResponses = db.relationship('InvitationResponse', backref = db.backref('invitation', uselist=False))


class InvitationResponse(db.Model):
    id = db.Column(db.Integer, primary_key = True)
    invitation_id = db.Column(db.Integer, db.ForeignKey('invitation.id'))
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    attending = db.Column(db.Boolean)
4

0 回答 0