title: Achieve a transitive association for a query in SailsJS
body: <p>My question might be an obvious one, however i've been struggling with this one for a couple of nights. Here's a basic overview of my problem.</p>
  <p>I have the following three models:</p>
  <h3>Model 1</h3>
  <pre class="lang-js prettyprint-override"><code>/* api/models/Parent.js */
  
  module.exports = {
    tableName: &quot;table1&quot;,
    attributes: {
      name: {
        type: &quot;string&quot;,
      },
      children: {
        collection: &quot;child&quot;,
        via: &quot;parentId&quot;
      },
    },
  };
  
  </code></pre>
  <h3>Model 2</h3>
  <pre class="lang-js prettyprint-override"><code>/* api/models/Child.js */
  
  module.exports = {
    tableName: &quot;table2&quot;,
    attributes: {
      name: {
        type: &quot;string&quot;,
      },
      parentId: {
        model: &quot;parent&quot;
      },
      vaccinations: {
        collection: &quot;vaccination&quot;,
        via: &quot;childId&quot;
      },
    },
  };
  
  </code></pre>
  <h3>Model 3</h3>
  <pre class="lang-js prettyprint-override"><code>/* api/models/Result.js */
  
  module.exports = {
    tableName: &quot;table3&quot;,
    attributes: {
      name: {
        type: &quot;string&quot;,
      },
      childId: {
        model: &quot;child&quot;
      },
      vaccinationId: {
        model: &quot;vaccination&quot;
      },
    },
  };
  
  </code></pre>
  <p>I wish to be able to query the following
  <code>GET /vaccination?parentId=1</code> which will retrieve all vaccinations for children that have <code>parentId=1</code>. I am not sure what's the best practice to follow here, i would really appreciate any help. I have read the <a href="https://sailsjs.com/documentation/concepts/models-and-orm/associations/through-associations" rel="nofollow noreferrer">Through Associations</a> but for some reason, i can not get it to work.</p>
  <p>Thanks in advance.</p>