0
我試圖在書架的任何想法中獲得以下查詢? (這個查詢工作,並返回所需的結果)書架的嵌套查詢
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'
還有一個問題,我使用的是屬於關聯和的hasMany(例如)後,我預計返回的對象將是類似於
restaurants (obj)
meals (obj)
visitorsMealsCount (attribute)