uptrace / bun

SQL-first Golang ORM
https://bun.uptrace.dev
BSD 2-Clause "Simplified" License
3.47k stars 210 forks source link

[Feat] Can the JoinModel method be supported? #940

Open ilxqx opened 7 months ago

ilxqx commented 7 months ago

Just like db.NewSelect().Model(entity), after specifying the Model, you can read the table name and alias information automatically. However, it is a bit difficult for Join because we need to hardcode the table name and alias ourselves. This work is obviously redundant and unnecessary. I think we can completely solve this problem by using the concept of JoinModel (similar to Model), which can improve efficiency and reduce code duplication.

At the same time, for Join, although we need to write INNER JOIN or LEFT/RIGHT JOIN ourselves, I also think this can be solved by adding a few methods:

I have an idea to submit a Pull Request, but before that, I would like to discuss their feasibility first.