Nico
Explore posts from serversDTDrizzle Team
•Created by Nico on 10/30/2024 in #help
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?5 replies
DTDrizzle Team
•Created by Nico on 9/28/2024 in #help
Subqueries in insert statements
I have the following schema (in sqlite)
When inserting into
job_titles
, in SQL, I've done the following to get the correct language_id
given a language.code
:
Is there a way to do this in Drizzle outside of using the sql
function and writing the wrong string? Right now, I've just writen a Typescript function to recreate the functionality but I just want to know if there's other approaches3 replies