drizzle-team / drizzle-team/drizzle-orm
[FEATURE]: Add support to create standalone joins and apply them to query
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Describe what you want
Drizzle already supports creating standalone `SQL` objects for where and orderBy clauses like:
```
const myWhere = gt(customerTable.salary, 5000);
const myOrderBy = desc(customerTable.salary)
```
and apply them later to a (dynamic) query:
```
const query = db
.select()
.from(customerTable)
.where(myWhere)
.where(myOrderBy);
```
For creating dynamic queries it would be very helpful to do the same for joins.
```
const myJoin1 = leftJoin(countryTable, eq(countryTable.id, customerTable.countryId));
const myJoin2 = innerJoin(continentTable, eq(continentTable.id, countryTable.continentId));
const query = db
.select()
.from(customerTable)
.join([myJoin1, myJoin2])
.where(myWhere)
.where(myOrderBy);
```
/cc @AlexBlokh
https://discord.com/channels/1043890932593987624/1279728243188174879
https://discord.com/channels/1043890932593987624/1282601056244858910
Contributor guide
Assessment
This issue has not been assessed yet.