0

如何将此原始 SQL 查询转换为 Gino ORM 查询?

我正在使用 FastAPI Web 框架和 Gino ORM,因为它是异步的。我只想知道是否可以将某个查询转换为 ORM 语法。

这是有效的原始查询。

select *, coalesce(sum, 0) as count_like from 
    (select sub_group.post_owner, sum(sub_group.count_like) from 
        (SELECT "post".owner_id as post_owner, "like".owner_id as like_owner,
        COUNT("like".post_id) as count_like
        from "post"
        INNER JOIN "like" ON "post".id = "like".post_id
        GROUP BY  "post".owner_id, "like".owner_id) as sub_group
    group by sub_group.post_owner) as sub_users
right join "user" on "user".id = sub_users.post_owner
order by count_like desc

有人可以帮助将此 sql 查询转换为 Gino ORM 查询吗?

4

0 回答 0