Skip to content

[FEATURE]: Add query automatic population for the foreign key relations. #4946

@SandipGyawali

Description

@SandipGyawali

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Currently, Drizzle ORM requires manual joins and explicit field selection to fetch related data, which can be repetitive and verbose for common parent-child queries.

Request:

-> I would like to request the addition of a built-in feature that supports automatic relation population or nested includes, similar to what ORMs like Prisma provide. This feature would allow developers to:

Fetch related entities in a single query with a simple, declarative API.
Receive nested objects in the query result without manually mapping or restructuring the output.
Improve developer experience by reducing boilerplate join and mapping code.

  1. Prisma: .findMany({ include: { plan: true } })
  2. TypeORM: .find({ relations: ['plan'] })
  3. Sequelize: .findAll({ include: Plan })

Expected in Drizzle ORM:

-> const subscriptions = await db.customerSubscription.findMany({
where: { userId: '...' },
include: { subscriptionPlan: true }
});

In Above code the subscriptionPlan is the foreign key for the customerSubscription which can be auto populate to get the row data automatically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions