我试图在书架中获得以下查询,任何想法? (此查询正在运行并返回所需的结果)
SELECT "restaurants".*, "meals".*, ( select count(*) from "public"."visitors" as "visitors" where "visitors"."meal_id" = "meals"."id") as "visitorsMealsCount" FROM "public"."restaurants" as "restaurants" inner join "public"."meals" as "meals" ON "meals"."restaurant_id" = "restaurants"."id" WHERE "restaurants"."id" = '123'
另一个问题,在我使用belongsTo和hasMany之后(例如)我预计返回对象将类似于
restaurants (obj)
meals (obj)
visitorsMealsCount (attribute)