© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
2 replies
ArwanceR

Relational query problem

My goal is to get object of this shape:
product: {
  ...
  images: [{...}, {...}, {...}]
}
product: {
  ...
  images: [{...}, {...}, {...}]
}


Product has relation to
images
images
- one-to-many,
export const productRelations = relations(products, ({ many}) => ({
  images: many(images)
}))
export const productRelations = relations(products, ({ many}) => ({
  images: many(images)
}))

and according to the docs: https://orm.drizzle.team/docs/joins#many-to-one-example
I should be able to do this:
const products = await db.select().from(products)
    .leftJoin(images, eq(images.productId, products.id)).all()
const products = await db.select().from(products)
    .leftJoin(images, eq(images.productId, products.id)).all()
(using postgres)
However, apparently, method
all()
all()
does not exist and I get an error:
db.select(...).from(...).leftJoin(...).all is not a function
db.select(...).from(...).leftJoin(...).all is not a function
.
If I'm doing something wrong please tell me.
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Nullable relational query?
Drizzle TeamDTDrizzle Team / help
3y ago
advanced relational query builder
Drizzle TeamDTDrizzle Team / help
3y ago
Drizzle relational query, filters
Drizzle TeamDTDrizzle Team / help
3y ago
totalCount from relational query
Drizzle TeamDTDrizzle Team / help
3y ago