title: How to limit domain results with criteria
body: <p>I am new to grails and I have a question about limiting a query result:
  domain User:</p>
  
  <pre><code>class User {    
      String login
      String password
      String fname
      String lname
      String role = "user"    
  
      static constraints = {
          login    (size:5..15, blank:false, unique:true, matches:"[a-zA-Z0-9]+")
          password (size:5..15, blank:false)
          fname    (blank:false)
          lname    (blank:false)
          role     (inList:["user", "admin"])
      }
  
      String toString(){
          fname &amp; " " &amp; lname
      }
  
      static mapping = {
          cache true
  
          columns {
              fname     type:'text'
              lname     type: 'text'
              password  type:'text'
              login     type:'text'
          }   
      }
  }
  </code></pre>
  
  <p>my GSP page snippet that displays the results:</p>
  
  <pre><code>&lt;g:each in="${userInstanceList}" status="i" var="userInstance"&gt;
    &lt;tr class="${(i % 2) == 0 ? 'odd' : 'even'}"&gt;
      &lt;td&gt;&lt;g:link action="show" id="${userInstance.id}"&gt;
        ${fieldValue(bean: userInstance, field:   "id")}&lt;/g:link&gt;&lt;/td&gt;
      &lt;td&gt;${fieldValue(bean: userInstance, field: "login")}&lt;/td&gt;
      &lt;td&gt;****&lt;/td&gt;
      &lt;td&gt;${fieldValue(bean: userInstance, field: "fname")}&lt;/td&gt;
      &lt;td&gt;${fieldValue(bean: userInstance, field: "lname")}&lt;/td&gt;
      &lt;td&gt;${fieldValue(bean: userInstance, field: "role")}&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/g:each&gt;
  </code></pre>
  
  <p>I call the controller with this code, in separate gsp view:</p>
  
  <pre><code>&lt;g:link class="users" controller="user" params="[sort:'fname',order:'desc']" action=""&gt;Manager Users&lt;/g:link&gt;
  </code></pre>
  
  <p>My question is, how do I call the domain and display the results according to the following criteria:  first, if the Role is admin, display everything.  If the role is not admin, only display the results of certain login value (ie, just show the results where the login = the current user)</p>
  
  <p>Thanks for your help!
  jason</p>