title: Using Raw Queries in a Sails App using Sequelize as ORM
body: <p>I am working with a sails application that uses Sequelize as the ORM tool. Initial integration between the app and Sequelize was established via the sails-hook-sequelize plugin which can be found <a href="https://www.npmjs.com/package/sails-hook-sequelize" rel="nofollow">here</a>. This approach has worked great so far, no problem defining and using models.</p>
  
  <p>However, I hit a road block when I wanted to define a View as a Sequelize object. Sequelize doesn't (yet) have an easy way to do this. The work around I found was to execute a raw query and populate a table with the result.</p>
  
  <p>Now I come to the second road block and the actual question itself. How do I simply execute a sequelize.query inside of my sails application? In stand alone node apps using sequelize I don't have a problem. However, this sails application has gotten away from me to the point where I'm not sure what object to actually call .query from! What I'm looking for is something simple like</p>
  
  <pre><code>Sequelize.query("SELECT * FROM `Document.MyView`", { type: Sequelize.QueryTypes.SELECT})
  </code></pre>
  
  <p>Sadly the above gives me <code>sequelize.query is not a function</code></p>
  
  <p>I have a connections.coffee file where the database connection is defined. It is named 'Core', however when I try <code>Core.query</code> I get <code>Core is undefined</code></p>
  
  <p>Seems like I am missing something simple and fundamental from stacking too many things on top of the other.</p>