Is it possible to return has many relationship load to return a single object instead of an array.

    db.query.products.findMany({
      orderBy: (model, { desc }) => desc(model.createdAt),
      with: {
        discounts: {
          where: (model, { eq }) =>
            eq(model.organizationId, session.organizationId),
          limit: 1,
        },
      },
    }),


output
[
  {
    id: 1,
    discounts: [ [Object] ]
  }
]


desired output

[
  {
    id: 1,
    discounts: Object
  }
]
Was this page helpful?