title: SailsJS / Waterline - How do I use a 'string' index in models and associations?
body: <p>Newbie question here.</p>
  
  <p>According to <a href="https://github.com/balderdashy/waterline#indexing" rel="nofollow">https://github.com/balderdashy/waterline#indexing</a> you cannot use a 'string' datatype as an index in Waterline due to issues with case insensitivity:</p>
  
  <blockquote>
    <p>There is currently an issue with adding indexes to string fields. Because Waterline performs its queries in a case insensitive manner, we are unable to use the index on a string attribute. There are some workarounds being discussed but nothing is implemented so far. This will be updated in the near future to fully support indexes on strings.</p>
  </blockquote>
  
  <p>The problems I'm concerned with are: performance; associations using 'string' keys aren't possible.</p>
  
  <p>My questions are:</p>
  
  <ol>
  <li>Does it in fact index on strings if told to do so? If so, then what is the index based on: a) the original string as is; b) lowercase of the string; c) UPPERCASE of the string?</li>
  <li>If it doesn't index on strings at all, as is implied if you can assume that 'cannot use' means 'does not create', then does that mean that Waterline / database backend does a non-indexed record-by-record retrieve and compare? Seems highly inefficient, if so.</li>
  <li>Are 'string' and 'text' datatypes both affected or can I use 'text', in which case, question #2 needs to answered for 'text' datatypes, too.</li>
  <li>If you really can't use 'string', what should I use instead for foreign keys? An integer ID and a join table to bind another table with the string values? (Seems wasteful but workable for something like a keywords list).</li>
  <li>If, and when, will this 'issue' be fixed?</li>
  <li>What and/or where are the 'workarounds being discussed'?</li>
  <li>Is there a better ORM I should look at or just use native SQL methods (FYI, I'm using PostgreSQL).</li>
  </ol>
  
  <p>My hoped for answer here is:
  'string' can be indexed but queries against 'string' datatypes are performed using lowercase (or uppercase, but let me know which). As such, I can have a 'string' key so long as the case is correct.</p>
  
  <p>Also, I assume 'string' and 'text' are effectively synonymous in Waterline, at least outside of the database's native context.</p>
  
  <p>Thanks in advance for any help here.</p>