Relational query problem

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


Product has relation to images
  • one-to-many,
    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()
    (using postgres)
    However, apparently, method all() does not exist and I get an error:
    db.select(...).from(...).leftJoin(...).all is not a function.
    If I'm doing something wrong please tell me.
Was this page helpful?