Help with relations: many-to-many + one-to-one
I'm having trouble figuring out how to model the following relationships between papers, authors, and author's names with Drizzle
relations
. The schema looks like this (I've ommitted some columns for brevity)
Conceptually, the relations are as follows:
- each row in authors
can be related to many rows in papers
, and each row in papers
can be related to many rows authors
(many to many)
- each row in authors_to_papers
is be associated with one row of authors
Here are the relations I have set up:
I know that I can do the following to return a paper with it's author(s):
But how do I get from the authorId
s returned in the output of the above to the firstName
and lastName
associated with those authorId
s?3 Replies
👋 maybe like that? https://drizzle.run/k8ctyqfcoen0gepuz9ma2g3p
Drizzle Run
sqlite relations example - Drizzle Run
Yes this worked! Thank you so much!
I thought I had tried that but it didn't work.