.all() API not available

I have two tables that I want to join, and I want to join them to get the following result:
type Result = {
platform: Platform
founders Founder[]
}
type Result = {
platform: Platform
founders Founder[]
}
export const getPlatformData = async (platformName: string) => {
const { ...platformFields } = getTableColumns(platforms);

const platformData = await db
.select({
...platformFields,
founders: {
name: founders.name,
},
})
.from(platforms)
.innerJoin(founders, eq(founders.platformId, platforms.id))
.where(eq(platforms.name, platformName));

return platformData[0];
export const getPlatformData = async (platformName: string) => {
const { ...platformFields } = getTableColumns(platforms);

const platformData = await db
.select({
...platformFields,
founders: {
name: founders.name,
},
})
.from(platforms)
.innerJoin(founders, eq(founders.platformId, platforms.id))
.where(eq(platforms.name, platformName));

return platformData[0];
Right now, I only get back a single Founder with the join, so I wanted to use the .all() API, but it just didn't work. How would I do this?
1 Reply
gdalmau
gdalmau13mo ago
Inner join will return a 1:1 record each time. You could try grouping but my preferred method would be to use the query relationships. They come quite handy in situations like this. https://orm.drizzle.team/docs/rqb
Drizzle Queries - DrizzleORM
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind
Want results from more Discord servers?
Add your server