drizzle-team / drizzle-team/drizzle-orm

[FEATURE]: custom query as relation ( to be used as a sub query or join )

Open
#4,845 3 comments 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Feature hasn't been suggested before.

- [x] I have verified this feature I'm about to request hasn't been suggested before.

### Describe the enhancement you want to request

It would be really good and useful if we can define relations based on queries instead of field to field.
for example something like this :
```ts
const userRelations = relation(user,({customOne})=>({
friends: qb => qb.select().from(something).join(users).groupBy(...)
}))
```
this is just an example it could get arbitrarily complex (specially with havings and group by stuff ).
the default where in rqb2 is really useful but not as flexible as this could be.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.