Return to Snippet

Revision: 37823
at December 17, 2010 21:56 by guava


Initial Code
params.max = Math.min(params.max ? params.int('max') : 20, 100)
if (!params.sort) params.sort = "lastUpdated"
if (!params.order) params.order = "desc"
if (!params.offset) params.offset = 0
def user = session.user
def query= "from Project p where exists ( from Member m where p.id = m.project.id and m.user.login='"+user.login+"') order by p." +params.sort+ " " +params.order+ "";
            
def projectList  = Project.findAll(query,[max:params.max?.toInteger(), offset:params.offset?.toInteger()])
            
def projectTotalCount = Project.findAll(query).size()
           
[projectInstanceList: projectList, projectInstanceTotal: projectTotalCount]

Initial URL

                                

Initial Description
Select all projects where the current user is  a member. 
A project has a set of members where each member is comprised of user and role.

Initial Title
Grails : Select all projects where the current user is  a member.

Initial Tags
query

Initial Language
Groovy