I'm trying to create a simple join and after reading the docs, can't
understand how it's actually performed. I have a set of users and a set of
images. I also have a set of UserImages, where multiple users can point to
the same image. I've been able to do simple queries on the individual
tables, but I'm at a loss on how to get all the images for a given user.
class User(Entity):
email = Field(UnicodeText)
class Image(Entity):
url = Field(UnicodeText, unique=True)
class UserImage(Entity):
user = ManyToOne('User')
thumbnail = ManyToOne('Image')
I know I can do something like the following to get all the UserImages...
UserImage.query.filter_by(user=user)
...but I'd like to join that with the actual list images that are linked.
I'm just using sqlite right now for testing if that makes a difference.
Reading the relationship docs, I don't understand this "joined table" like
it's supposed to actually exist statically. Can someone give me the syntax
to do something like this? Would I have to end up with all the Images or
would I have a join of the UserImages and Images? While the images are
shared, I figured there might be data on the userimage later like "link"
date so I'd end up with a list of images a user is linked to, but also a
column of the creation date. Thanks, any help or even direction would be
appreciated.
--
You received this message because you are subscribed to the Google Groups
"SQLElixir" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlelixir.
For more options, visit https://groups.google.com/groups/opt_out.