[GH-ISSUE #65] Including relational data? #45

Closed
opened 2026-02-26 01:32:58 +03:00 by kerem · 5 comments
Owner

Originally created by @jcrben on GitHub (Oct 30, 2017).
Original GitHub issue: https://github.com/jeffknupp/sandman2/issues/65

I was messing around with PostgREST before this and they have the concept of resource embedding to pull in related data. Is there anything similar here? It also seems like https://github.com/pyeve/eve-sqlalchemy supports this.

With sandman(1), it seems like the docs suggest that there should be links - altho there is a field named links, it's not clear how that relates to items:
image

With sandman2, I don't even see a link:
image

Schema constructed with a simple many-to-many relationship:

users_items_assoc = Table('users_items_assoc', Base.metadata,
                          Column('users_items_assoc_id', Integer, primary_key=True),
                          Column('user_id', Integer, ForeignKey('users.id')),
                          Column('item_id', Integer, ForeignKey('items.id'))
                          )

class User(Base):
    __tablename__ = 'users'
    id = Column(Integer, primary_key=True)
    name = Column(String)
    nickname = Column(String)

    items = relationship('Item', back_populates='users', secondary=users_items_assoc)

    def __repr__(self):
        return f'{self.name}'


class Item(Base):
    __tablename__ = 'items'
    id = Column(Integer, primary_key=True)
    name = Column(String)
    description = Column(String)

    users = relationship('User', back_populates='items', secondary=users_items_assoc)
    # TODO: add image, upc, and so on

    def __repr__(self):
        return f'{self.name}'
Originally created by @jcrben on GitHub (Oct 30, 2017). Original GitHub issue: https://github.com/jeffknupp/sandman2/issues/65 I was messing around with PostgREST before this and they have the concept of resource embedding to pull in related data. Is there anything similar here? It also seems like https://github.com/pyeve/eve-sqlalchemy supports this. With sandman(1), it seems like the docs suggest that there should be links - altho there is a field named links, it's not clear how that relates to items: ![image](https://user-images.githubusercontent.com/5614134/32151347-6f7407a4-bcd9-11e7-8936-70c1062bff66.png) With sandman2, I don't even see a link: ![image](https://user-images.githubusercontent.com/5614134/32151380-9ae5585c-bcd9-11e7-9c84-12483e7033af.png) Schema constructed with a simple many-to-many relationship: ``` users_items_assoc = Table('users_items_assoc', Base.metadata, Column('users_items_assoc_id', Integer, primary_key=True), Column('user_id', Integer, ForeignKey('users.id')), Column('item_id', Integer, ForeignKey('items.id')) ) class User(Base): __tablename__ = 'users' id = Column(Integer, primary_key=True) name = Column(String) nickname = Column(String) items = relationship('Item', back_populates='users', secondary=users_items_assoc) def __repr__(self): return f'{self.name}' class Item(Base): __tablename__ = 'items' id = Column(Integer, primary_key=True) name = Column(String) description = Column(String) users = relationship('User', back_populates='items', secondary=users_items_assoc) # TODO: add image, upc, and so on def __repr__(self): return f'{self.name}' ```
kerem closed this issue 2026-02-26 01:32:58 +03:00
Author
Owner

@jcrben commented on GitHub (Nov 19, 2017):

Closing this as I have decided not to use this library.

<!-- gh-comment-id:345553336 --> @jcrben commented on GitHub (Nov 19, 2017): Closing this as I have decided not to use this library.
Author
Owner

@rrjanbiah commented on GitHub (Jan 15, 2019):

Same question here.

@jcrben What library or approach did you choose?

<!-- gh-comment-id:454524841 --> @rrjanbiah commented on GitHub (Jan 15, 2019): Same question here. @jcrben What library or approach did you choose?
Author
Owner

@jeffknupp commented on GitHub (Jan 16, 2019):

@jcrben @rrjanbiah sandman2 uses the Link Header, which is how this information is meant to be conveyed; you'll find all of the data you're looking for there.

<!-- gh-comment-id:454886757 --> @jeffknupp commented on GitHub (Jan 16, 2019): @jcrben @rrjanbiah `sandman2` uses the Link Header, which is how this information is meant to be conveyed; you'll find all of the data you're looking for there.
Author
Owner

@rrjanbiah commented on GitHub (Jan 17, 2019):

@jeffknupp Thank you!

<!-- gh-comment-id:455031127 --> @rrjanbiah commented on GitHub (Jan 17, 2019): @jeffknupp Thank you!
Author
Owner

@mrhaoji commented on GitHub (Apr 16, 2020):

Where can I find the "Link Header"? in the response Header? @jeffknupp

<!-- gh-comment-id:614381792 --> @mrhaoji commented on GitHub (Apr 16, 2020): Where can I find the "Link Header"? in the response Header? @jeffknupp
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/sandman2-jeffknupp#45
No description provided.