Full SQL statements with Ti Alloy collections

Filed under: mobile and titanium Tagged: alloy, sqlite, and backbonejs
01 February, 2013

Prior to version Alloy 0.3.5 the sql adapter only supported SELECT * FROM table_name which left much to be desired. However, which the release of 0.3.5 you can now query to your heart desire.

  var Library = Alloy.createCollection('book');
      query: 'SELECT * FROM table_1 INNER JOIN table_2 ON table_1.id=table_2.id'

The key here is a key change to the sql adapter. To get this functionality in your Collections you'll need to change your models' adpater type from 'sql' to 'sql_new'. This hits the new adapter and allows for the query option. Once Alloy 1.0 releases the adapter will return to just 'sql' but retain the new functionality.

comments powered by Disqus