我在 Yesod 应用程序中定义了以下模型:
CvCategory
title Text
order Int
UniqueCvCategory title
CvItem
category CvCategoryId
title Text
fromYear Int
toYear Int Maybe
description Text Maybe
UniqueCvItem title
我在处理程序中有以下查询:
cvcategories <- selectList [] [] --all cv categories
在我的小村庄模板中,我想做类似的事情:
<ul>
$forall cvcategory <- cvcategories
<li>$#{cvCategoryTitle cvcategory}
$forall cvitem <- cvcategory --how?
<li>#{cvItemTitle cvitem}
在 Django 中,您可以轻松定义 a related_name
,然后使用它轻松访问所有“子对象”。Yesod也有可能吗?如何?