我想在我的用户模型中添加一个属性,以返回Project表中具有该用户ID的行数。大致如下...
def numProjects = {
/* somehow get count from Project table
The straight sql would be:
SELECT COUNT(*) FROM projects WHERE userId = <the current user>
*/
}