title: Level 2 (related model) scope over REST - strongloop api
body: <p>I found in the documentation that <a href="https://docs.strongloop.com/display/public/LB/Model+definition+JSON+file#ModeldefinitionJSONfile-Scopes" rel="nofollow">scopes</a> enable you to specify commonly-used queries that you can reference as method calls on a model. Below i have a <code>categories</code> model. I am trying to create scopes that applies to the relation with model <code>games</code>. Unfortunately the below does nothing. How can I get scopes to apply to relation as shown below?</p>
  
  <p><code>GET /Categories/{id}/games</code> - This gets all games </p>
  
  <p><em>common/models/category.json</em></p>
  
  <pre><code>"relations": {
      "categories": {
        "type": "hasMany",
        "model": "game",
        "foreignKey": ""
      }
  },
  </code></pre>
  
  <p><em>/common/models/game.json</em></p>
  
  <pre><code> "scopes": {
      "mature": {"where": {"mature": true}}
    },
    "validations": [],
    "relations": {
      "category": {
        "type": "belongsTo",
        "model": "category",
        "foreignKey": ""
      }
    }
  </code></pre>
  
  <p>I want to be able to get the data through endpoing: <code>/Categories/{id}/games/mature</code></p>
  
  <p>Table schema:</p>
  
  <pre><code>catgories
  
  category_name       category_id 
  -------------       -----------
  fighting            1001
  racing              1002
  sports              1003
  
  games
  
  game_id         game_name           category_id     mature
  -----------     ------------        -----------     --------------
  13KXZ74XL8M     Tekken              10001           true
  138XZ5LPJgM     Forza               10002           false
  </code></pre>