tortoise/tortoise-orm

Join Function

fruitoiz opened this issue · 1 comments

Can I use the join function in Tortoise?

I need to run this code on sql:

SELECT `t1`.id, `t1`.name, `t1`.description, `t1`.emoji, `t2`.id, `t2`.user_id, `t2`.achivka_id, `t2`.created FROM userachivki AS `t2` INNER JOIN achivki AS `t1` ON (`t1`.id = `t2`.achivka_id) WHERE (`t2`.user_id = 100) LIMIT 6 OFFSET 0

But I didn't find how to do it in the library.

The 'ForeignKeyField' option doesn't suit me. Tell me how to do this via 'join'.

As far as I understand, this function does not exist. But please add it!

It should be something like

UserAchivka.filter(user_id=100).select_related("achivka").limit(6)