On Sat, Mar 16, 2019 at 9:33 AM kosta <naumo...@gmail.com> wrote: > > Hello everyone! > > I've designed invitation model > class User(Base): > __tablename__ = 'user' > > id = Column(Integer, primary_key=True) > name = Column(String(64)) > email = Column(String(64)) > class Invitation(Base): > __tablename__ = 'invitation' > > id = Column(Integer, primary_key=True) > sender_id = Column(Integer, ForeignKey('user.id')) > invitee_id = Column(Integer, ForeignKey('user.id'), unique=True) > sender = relationship('User', foreign_keys=[sender_id], backref='invite_list') > invitee = relationship('User', foreign_keys=[invitee_id], > backref='invited_by', uselist=False) > > email = Column(String) > phone = Column(String) > token = Column(String) > > My logic is: > > 1. Create a new record in Invitation table: sender_id - current user, email > or phone and unique generated token. > 2. Create a new record in User table keep received token, commit it. > 3. Find a record in Invitation table by filter token and update filed > invitee_id == new_user.id > > > My problem is backref return value for invited_by - return (of course) > Invitation record. > My question is whether I've possibility return for invited_by User record via > Invitation table or not?
you can find any record via anything, what SQL would you like to emit please ? > > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy+unsubscr...@googlegroups.com. > To post to this group, send email to sqlalchemy@googlegroups.com. > Visit this group at https://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.