我怎样才能包括没有坐垫的孙子孙女?

时间:2014-03-19 14:52:30

标签: python flask flask-sqlalchemy flask-restless

我有以下实体。当我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)

0 个答案:

没有答案